Programmer Question
Hi,
I'm struggling with my app that launches multiple instances of the
same Activity using the same intent. My main activity is of class type
A and it does a startActivity() of two children that are of the same
class type B. So we have B1 and B2 launched. If B1 and B2 are both
paused (by pushing back button and making sure finish() is not invoked
on them so they are truly paused), how can A uniquely bring either B1
or B2 to the foreground again? I do want to launch a new B activity. I
want to uniquely bring B1 or B2 to the foreground.
so both B1 and B2 were created like this...
Intent intent = new Intent(context, B.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
Now I want A to bring B1 (or B2) to the foreground/front so I use the
below code, but how do I distinguish B1 or B2 when starting the
activity? This only brings the last instance of B that was on top to
the foreground.
Intent intent = new Intent(context, B.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
startActivity(intent);
I've tried keeping around references to B1 and B2 and doing something
like this, but this also only goes to the last instance of activity
class B that was on top...
Intent intent = new Intent(B1context, B.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
B1context.startActivity(intent);
I even tried this, but it still doesnt get me my unique B1 or B2...
Intent intent = B1.getIntent(); // i.e. the original intent that
started me
startActivity(intent); // still only brings to front the last B that
was on top.
Thanks in advance!
Find the answer here
No comments:
Post a Comment