Issue
I have 2 Activities ActivityA
& ActivityB
, if you open ActivityA
and select anything from it, it will open ActivityB
, and when you finish ActivityB
it will go back to ActivityA
, how can i open ActivityB
lets say from a notification, and when user finishs it, if there is nothing in back stack I opens ActivityA
, am asking about the best solution for this, I already have ideas about that, but still not sure if this is the best solution for it.
in ActivityB
Intent intent=new Intent(getApplicationContext(), ActivityA.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(intent);
finish();
or I can send a flag from ActivityA
to ActivityB
when I start B
from A
, if this flag exists, I just finish, if not, I start ActivityA
.
Solution
use startActivities() and pass both activities. Android will handle the back stack for you
Answered By - Mahdi Hijazi
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.