Issue
For example,
I have activity A, B, C, D
A call B
Intent intent = new Intent(A,B.class);
startActivity(intent);
Then, B call C
Intent intent = new Intent(B,C.class);
startActivity(intent);
After that, C call D
Intent intent = new Intent(C,D.class);
startActivity(intent);
In Activity D, I call finish()
. It will return back to Activity C.
My question is how can I clear Activity A, B, C before calling finish()
so that the app quit like normal.
Don't suggest call finish()
on every startactivity
because the app can press back to previous activity to continue.
Solution
This should work definitely...
Intent intent = new Intent(D,A.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra("close",true);
startActivity(intent);
and in oncreat of A activity u have to write
if (getIntent().getBooleanExtra("close", false)) {finish();
}
else {
{
//ur previous code here
}
Have fun if any problem u can ask
Answered By - Dinakar Prasad Maurya
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.