Android - Can I force BACK button to go 2 steps back in the Acitivty stack with some kind of code? I know I can override the onKeyDown method but I want BACK to do it's thing, just twice!
views:
331answers:
3I am thinking of it this way:
A -> B -> C
A,B,C activities.
You can't do a back twice since the first onKeyDown
will be executed in C and the second one should be executed in B.
I don't know why you are trying to do, but here are some options.
a) Using the android:noHistory tag:
Perhaps your C activity is doing something that doesn't need a view and that's why you want to back twice.
b) Using an intent. Something like:
Intent intent = new Intent(C.this, A.class);
startActivity(intent);
c) Using the [finishActivityFromChild() method][2]. I have never try it, but it looks like you can use it to decide what to do on B depending of how C ended.
There's an Android Devlopers blog about using the back key here - http://android-developers.blogspot.com/2009/12/back-and-other-hard-keys-three-stories.html
Just set it up to go back to whichever activity you want
please refer the link below for clearing intent from stack trace with the use of flags.