activity-finish

Android : startActivityForResult() with BACK button functionality

梦想的初衷 提交于 2019-12-10 01:19:14
问题 I would like to start a new activity for a result , with startActvityForResult() , but I would like to have the back button working as normal in the new activity. Currently when I invoke a new Activity for result, nothing happens when I press the back button in the new Activity. I tried something like this: @Override public void onBackPressed() { setResult(0); super.onBackPressed(); finish(); } in the new Activity, but it didn't work. Still nothing happens when the back button is pressed. Is

what is the right way to clear background activity/activites from stack?

拟墨画扇 提交于 2019-12-09 01:49:10
问题 as the questions title says - I need to know what is the best way to "remove"/destroy/finish an activity that are somewhere in the middle of stack and currently on pause mode (not specific instances - but specific derived classes). for example: if the current state of the stack looks like this: ActivityD <-- top of the stack, currently forground ActivityC ActivityA ActivityC ActivityA a request to "clear" all ActivityC instances would cause the stack to be like: ActivityD <-- still top of the

Calling finish() removes the activity from activity stack?

廉价感情. 提交于 2019-12-08 12:43:49
问题 I have made an application where I start activity 'Pin' after I start activity A (activity A has noHistory= true , so it will not stay on stack). If no pin has been set up; PinActivity also starts an activity NewPinActivity . After setting pin, NewPinActivity calls finish() and goes back to PinActivity . Where you will give appropriate pin, it will call finish() on it and it will move again to activity A (Since activity A had noHistory=true , so I have to start a new instance of activity A ).

How to finish an activity when transition is done Android

岁酱吖の 提交于 2019-12-07 22:58:17
问题 i want to end a previous activity after the transition between 2 activities is completed i have tried ActivityCompat.finishAfterTransition(this); but it actually finishes the activity before the transition is done i have looked into this solution before but i couldn't understand the answer to it , it would be swell if someone can explain how to end an activity after the transition is done Updates : i just tried starting the next activity like this Intent intent = new Intent(LoginActivity.this

how back to the main activity in android?

会有一股神秘感。 提交于 2019-12-07 14:24:43
问题 I have a MainActivity "A", which have a button that launch activity "B", and activity "B" have another button that launch activity "C". In the activities B and C, both have onBackPressed() method, which appears an AlertDialog asking if the user wants to return to MainActivity . If they press yes, the program should show MainActiviy. The question is: in activity B, i have not problem, simply call the finish() method, and MainActivity appears, but the problem is in activity C, if i call a

How to finish an activity when transition is done Android

余生颓废 提交于 2019-12-06 15:42:12
i want to end a previous activity after the transition between 2 activities is completed i have tried ActivityCompat.finishAfterTransition(this); but it actually finishes the activity before the transition is done i have looked into this solution before but i couldn't understand the answer to it , it would be swell if someone can explain how to end an activity after the transition is done Updates : i just tried starting the next activity like this Intent intent = new Intent(LoginActivity.this, TaskActivity.class); startActivity(intent); the onStop code will be activated but when i use this

finish activity in onActivityResult does not work

大兔子大兔子 提交于 2019-12-06 05:13:36
问题 I have a pair of activities that must live or die together. Basically AlphaActivity does some work and then dispatches an intent ( startActivityForResult() ) for BetaActivity. When BetaActivity is done, I want it to dispatch an intent ( startActivity() ) for GammaActivity and then call finish() on itself. Upon finishing I was hoping for AlphaActivity's onActivityResult() method to be called, but that never seems to happen. My design is such that inside AlphaActivity's onActivityResult() , I

Android: When to end class with finish()?

不羁岁月 提交于 2019-12-06 03:38:33
问题 I often see examples of classes which end with finish() , but definitely not always. My question is when should you end a class with finish() ? And what does it do exactly, what is the difference between ending a class with the back button and ending it with finish() ? Thanks in advance! 回答1: finish() can be called to kill (destroy) an Activity instance. If you don't need to close your Activity manual, which is true in many cases, you don't need to call this method. But if you require a

how back to the main activity in android?

江枫思渺然 提交于 2019-12-05 18:31:20
I have a MainActivity "A", which have a button that launch activity "B", and activity "B" have another button that launch activity "C". In the activities B and C, both have onBackPressed() method, which appears an AlertDialog asking if the user wants to return to MainActivity . If they press yes, the program should show MainActiviy. The question is: in activity B, i have not problem, simply call the finish() method, and MainActivity appears, but the problem is in activity C, if i call a finish() method, the program is back to activity B. How back to MainActivity from activity C?? try this on

Finish All Instance of particular Activity

杀马特。学长 韩版系。学妹 提交于 2019-12-05 07:46:26
There can be many activities in application and the last launched activity stay on top of stack and on pressing back it finish the current activity.I have a sequence of Activity and here is the flow .. if we have A,B, C(1) ,D, C(2) ... Activity C(1) and C(2) are two different instance of Activity C launched while navigating the application .So what is requisite is to clear all the instance of activity C and the result should be when I finish C(2) I should have left with these stack A,B,D . What should I do . IMP -I want to keep the C(1) alive in stack until unless I finish the C(2) as I could