activity-finish

Difference between finish() and System.exit(0)

江枫思渺然 提交于 2019-12-17 06:11:57
问题 I'm talking about programming in android. In early days I thought that, finish() closes current activity and go back to the previous in Activity stack, and System.exit(0) closes the whole application . But I was wrong. I made a small experiment and understood that Both will finish only the current Activity . The only differences that I could notice is that, in Android 2.3.3 The ActivityResult is propagated back to onActivityResult() using finish() . Whereas onActivityResult() not called for

Finish activity from another activity

江枫思渺然 提交于 2019-12-13 14:20:12
问题 I have 3 activities A, B and C. A leads to B which leads to C. I would like to be able to move back and forth between A and B but I want to finish both A and B once C gets started. I understand how to close B when starting C via the intent but how do I also close A when C gets started? 回答1: In your onCreate() method assign a static instance to a variable to create a Singleton: public static ActivityA instance = null; public void onCreate(Bundle savedInstanceState) { super.onCreate

onActivityResult is not been invoked after the child activity calls finish()

北慕城南 提交于 2019-12-12 10:22:58
问题 Though there are several questions regarding this topic, I could not find a right answer to this. I have a main activity (This is one activity in a tabview) from where I am calling the login activity. Button chdbtn=(Button)findViewById(R.id.Add); chdbtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent myIntent = new Intent(main.this, Login.class); startActivityForResult(myIntent, 1001); } }); protected void onActivityResult(int requestCode, int

What is the difference between finish() and ActivityName.this.finish()?

 ̄綄美尐妖づ 提交于 2019-12-12 04:36:00
问题 Is there any difference between finish() and ActivityName.this.finish() ? If we have activity with name SampleActivity , we can finish it by calling finish() and by SampleActivity.this.finish() . What is the difference? 回答1: Most of the time it's the same except if you are inside an inner class. In that case the second notation is used to disambiguate calls to the containing activity's methods. For instance: @Override public void onCreate(Bundle savedInstanceState) { super.onCreate

finish() not working as expected

落花浮王杯 提交于 2019-12-12 03:29:38
问题 As I'm creating an android application in which first I've created main activity, then I've added splash activity along with the one normal activity. So my problem is whenever I click on exit in my app it closes the main activity and returns that one normal activity in splash activity. I am using finish(); on exit button which is present in main activity. So how can I exit the app which comes to android launcher screen I've also tried creating new intent with Action Main but its only

Finish subclass activity from its superclass

落爺英雄遲暮 提交于 2019-12-11 09:26:14
问题 Consider the following scenario: The class TemplateActivity extends Activity . Within onResume() it performs a validation of a boolean variable then, if false, it finishes the method and the activity, and starts a new activity, OtherActivity . When the class ChildActivity , which extends TemplateActivity , runs, it waits for super.onResume() to finish and then continue no matter if its super needs to start the Intent or not. The question: Is there a way to terminate the ChildActivity when the

exit button in android not working

元气小坏坏 提交于 2019-12-11 04:22:19
问题 I was trying to close app on click of button click.so i use the following code on home page closebtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub finish(); } }); from page5 clicking of close button Home page opens. b5.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub Intent i =new Intent(Page5.this, FirstPage.class); startActivity(i); } }); so when i

finish() activity twice in android?

假装没事ソ 提交于 2019-12-10 18:45:44
问题 Okay say your using a app, and you opened a new activity and then opened another, you can end the activity your on by using finish(); and your back one activity, but how can you go back two activities, all the way back to the first one? I know you could use: Intent savedGameIntent = new Intent(v.getContext(), firstclass.class); v.getContext().startActivity(savedGameIntent); But is that the best way to do it? 回答1: Use the flag Intent.FLAG_ACTIVITY_CLEAR_TOP. Intent intent = new Intent(this,A

Android clear / finish previous activities except one

别来无恙 提交于 2019-12-10 16:18:24
问题 In android I have the following path: Activity 1 -> Activity 2 -> Activity 3 -> ... Activity N -> press button ... When the button is pressed I want to Clear/Finish ALL activities from Activity 2 until N and then go to Acitivy X. In other words I want to finish all activities down to the initial One and then move to another. If I use the flags: CLEAR_TOP, CLEAR_TASK, NEW_TASK etc theoritically it would finish ALL previous activities with the initial one. Is there any way to keep the initial

how to achieve something like “finish” in a non-activity class in android?

▼魔方 西西 提交于 2019-12-10 14:52:45
问题 This dialog asks whether you want to install some other app...so when onclicked no button it must go back to the previous screen downloadDialog.setNegativeButton(stringButtonNo, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialogInterface, int i) { finish(); } }); this gives the error: The method finish() is undefined for the type new DialogInterface.OnClickListener(){} how can i achieve what i wanted??? package com.Android.barcode; import android.app.Activity;