Issue
I have some problems with controlling the previous button and lifecycle of app, this is scheme of my application, I try to describe my knowledge about it.
I can move between categories without any limitation. For example, I run my app the firts screen
which is named third category
then I move to second category
and then to third one
. When I click the previous button It moves me to second category
, because this was the previous screen, but I want that "physical previous button" exit from whole application, no matter what I made before, so it should switch every existing activity to onStop and onDestroy or how should be done?
I try to destroy previous category activity when I move to next one,by finish();
but I addedto onDestroy some methods which clears list, so during lifetime of application it's not desired thing.
Solution
use this code inside onBackPressed()
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
Other Solutions may help you.
Answered By - Ketan Ahir
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.