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)" <j...@google.com>
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 <henderson.jus...@gmail.com> 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 <tiandiji...@gmail.com> 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.

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

Reply via email to