Hi, I just replied to the bug, but should say something here as well --

This is intentional behavior, since launching a single task activity means
bringing it to the foreground, the stack is cleared so it can always receive
the new intent.  So for example Browser, which is one of the few single task
activities -- if it is launched from somewhere with a new URI the root
activity needs to be brought foreground to display it.

The solution is simple: don't use single task.  There are very very few
places where this is actually appropriate, and those few cases are for this
kind of special case behavior for the browser.

On Mon, Sep 28, 2009 at 6:52 AM, Johan Schöring <[email protected]> wrote:

>
> That's what the documentation says, but that's not what the
> ActivityManager does.
>
> From what I can see, the problem lies in the following code:
>
> http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=services/java/com/android/server/am/ActivityManagerService.java;h=a473db2740abe124b7867d0ea6313eb8c0ca7a7d;hb=5550ef48739a7bb16f80aa6b10e9c151b1438163#l3333
>
> The if-statement on line 3333 causes the activity stack to be cleared
> if the launch mode is singleTask, regardless of the state of
> FLAG_ACTIVITY_CLEAR_TOP... In my opinion, this is a bug, as the
> documentation you quoted clearly says that the stack should be
> preserved on a singleTask activity.
>
> I'm going to submit a patch for this, but I'm writing here so others
> who find this thread know that this behaviour is not their fault but a
> bug.
>
> // Johan
>
>
> On Sep 24, 10:02 pm, "Justin (Google Employee)" <[email protected]>
> wrote:
> > Fromhttp://developer.android.com/guide/topics/fundamentals.html#acttask
> >
> > "As noted above, there's never more than one instance of a
> > "singleTask" or "singleInstance" activity, so that instance is
> > expected to handle all new intents. A "singleInstance" activity is
> > always at the top of the stack (since it is the only activity in the
> > task), so it is always in position to handle the intent. However, a
> > "singleTask" activity may or may not have other activities above it in
> > the stack. If it does, it is not in position to handle the intent, and
> > the intent is dropped. (Even though the intent is dropped, its arrival
> > would have caused the task to come to the foreground, where it would
> > remain.)"
> >
> > Cheers,
> > Justin
> > Android Team @ Google
> >
> > On Sep 24, 11:45 am, justinh <[email protected]> wrote:
> >
> >
> >
> > > When users press on your icon again to "come back" they are launching
> > > your activity, not the settings activity. Where do you start the
> > > settings activity in your code? If it's outside of the onCreate/
> > > onStart/onResume methods then the user will have to repeat that action
> > > to get back there.
> >
> > > On Sep 24, 2:58 am, play_net <[email protected]> wrote:
> >
> > > > My manifest:
> > > >        <activity android:label="@string/app_name"
> > > > android:name="MainUI" android:screenOrientation="landscape"
> > > >
> android:configChanges="orientation|keyboardHidden"
> > > > android:launchMode="singleTask">
> > > >             <intent-filter>
> > > >                 <action android:name="android.intent.action.MAIN" />
> > > >                 <category
> > > > android:name="android.intent.category.LAUNCHER" />
> > > >             </intent-filter>
> > > >         </activity>
> > > >        <activity android:label="@string/settings_label"
> > > > android:name=".view.Settings"  android:configChanges="orientation|
> > > > keyboardHidden">
> > > >         </activity>
> >
> > > >    I press program's icon to start my program,and then open the
> > > > Settings activity through startActivityForResult(intent, SETTINGS).
> > > > Now i press the  home key  and start my program through program's
> > > > icon, at this time the Settings actitity will run OnDestroy() and be
> > > > destroyed. I can't understand why Settings activity is be destroyed
> > > > automatically? How can I make Settings activity still focus when
> users
> > > > come back.
> >
> > > > Thank all.
>
> >
>


-- 
Dianne Hackborn
Android framework engineer
[email protected]

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

--~--~---------~--~----~------------~-------~--~----~
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