Hi Mark,

Yeah the problem is that my activity uses a singleton, and if there
are multiple instances of the activity, they can conflict with each
other if they are all trying to use the singleton simultaneously:

TaskA:
  ActivityB .. singleton.runLongProcess(...);

Browser:
  Click link, launch new instance of ActivityB
  ActivityB ..singleton.runLongProcess(...);

the other issue is that this activity can appear anywhere in the
activity stack of my app, so I'm cautious about using the singleTask
flag, which seems like the closest thing to what I need. Up until now,
I've just been using the:

  FLAG_ACTIVITY_SINGLE_TOP
  FLAG_ACTIVITY_CLEAR_TOP

flags within the app to make sure that there is only one instance of
ActivityB running.

I tried the following test which did not work:

 -Start ActivityA from app tray (launcher, singleTask)
 -Start ActivityB from button in ActivityA
 -Home screen
 -Browser
 -Click link
 -Intent filter calls ActivityA.
 -Since ActivityA is singleTask, the already running activity is
resumed.
 -ActivityA::onNewIntent() is called.
 -Try to start intent to also resume ActivityB instance:

    Intent i = new Intent();
    i.setClass(this, ActivityB.class);
    i.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
    i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    startActivity(i);

that doesn't work though. The previous instance of ActivityB is not
restored, I just see ActivityB::onCreate() get called again, and this
second instance has a different memory address than the first one.

This is killer. I guess I could just make all of my activities
singleTask, but I know Dianne cautions against it and I don't want to
modify my app so profoundly by switching all the launchMode flags, I
don't know what side effects it will really have.

Thanks



On Feb 17, 5:05 am, Mark Murphy <[email protected]> wrote:
> Mark Wyszomierski wrote:
> > To clarify:
>
> > MyApp::ActivityA is running
>
> > Browser launches new MyApp::ActivityA instance.
>
> > Inside the new instance of MyApp::ActivityA, I want to be able to see
> > that there is already a previous instance of MyApp::ActivityA running,
> > close myself, and bring it to the foreground.
>
> > Is that possible?
>
> Check the various android:launchMode values for the <activity> element
> in the manifest to see if one fits your situation.
>
> --
> Mark Murphy (a Commons 
> Guy)http://commonsware.com|http://twitter.com/commonsguy
>
> Android Training...At Your Office:http://commonsware.com/training

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to