There was another thread about this recently.  This message summarizes
the behavior with singleTask

http://groups.google.com/group/android-developers/msg/471bef9e235f6c65

In short, with launchMode=singleTask the behavior after re-visiting
Home is different depending on whether the activity at the top of the
stack was started implicitly (with an intent filter) or explicitly
(with a class name).  ASFAIK this is not documented. Not clear if it
is a bug or not.


On Feb 26, 1:05 am, Neha <nehas...@gmail.com> wrote:
> Hi,
>
> Does anyone have any updates on this issue? I'm facing the same
> problem with my activity when launchMode=singleTask.
>  - Launcher -> Activity A (singleTask) -> Activity B (standard)
>  - Press HOME
>  - Long-press HOME or go to Launcher
>  - Activity A (B's onDestroy called)
>
> "adb shell dumpsys activity" shows only Activity A in the stack for
> this task. The intent flags are:
> Long press HOME - FLAG_ACTIVITY_NEW_TASK,
> FLAG_ACTIVITY_BROUGHT_TO_FRONT and FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
> Launcher - FLAG_ACTIVITY_NEW_TASK, FLAG_ACTIVITY_BROUGHT_TO_FRONT and
> FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
>
> Any pointers on how to fix this would be helpful.
> Thanks!
>
> On Feb 17, 10:41 pm, Dianne Hackborn <hack...@android.com> wrote:
>
> > When you say "launch" do you mean launching from Eclipse?  If so, there is a
> > bug in older SDKs where this would use the wrong intent so when you later
> > launch it from the launcher you would get a new task.
>
> > You can use "adb shell dumpsys activity" to see the current state of the
> > activity stack at whatever point you want to help diagnose what is going on.
>
> > On Thu, Mar 26, 2009 at 8:55 AM, jseghers <jsegh...@cequint.com> wrote:
>
> > > The code that starts the .About activity is:
> > >    protected void startAbout()
> > >    {
> > >        Intent aIntent = new Intent(this, About.class);
> > >        startActivity(aIntent);
> > >    }
>
> > > The Manifest entries for .UserLaunch and .About are in my original
> > > post.
> > > The intent that returns the task to the front is generated by the
> > > Launcher.
>
> > > What flags do I need to set (and where) to prevent this from
> > > happening? Is one of the default values causing it?
>
> > > My test case here is:
> > > 1) launch .UserLaunch from the launcher
> > > 2) start .About
> > > 3) hit Home key
> > > 4) launch .UserLuanch from the launcher
>
> > > There are no long delays in any of this, so the 30 minute auto-clear
> > > should not be invoked.
>
> > > - John
>
> > > On Mar 25, 12:15 pm, Dianne Hackborn <hack...@android.com> wrote:
> > > > That means you are using some CLEAR_TOP or finish flag in an intent or 
> > > > in
> > > > the manifest.  Or possibly it has been > 30 minutes since the app was
> > > last
> > > > launched, in which case the system will restart it automatically.
>
> > > > On Wed, Mar 25, 2009 at 11:12 AM, jseghers <jsegh...@cequint.com> wrote:
>
> > > > > Thank you for your reply!
>
> > > > > I am seeing am_task_to_front followed by am_finish_activity.
> > > > > I found the event-log-tags file and apparently the reason is "clear".
> > > > > What is not clear to me though is why the activity manager thinks it
> > > > > should clear the the task.
>
> > > > > The relevant lines of the log are:
> > > > > I/am_on_resume_called(   94): com.android.launcher.Launcher
> > > > > I/dvm_gc_info(   94):
> > > > > [7017575181485176104,-9053780441931634733,-4010030953047537782,8554533]
> > > > > I/force_gc(  209): bg
> > > > > I/dvm_gc_info(  209):
> > > > > [7163384747111232651,-9098816781953771608,-4017912252395432053,7919391]
> > > > > I/am_pause_activity(   52):
> > > > > [1128800640,com.android.launcher/.Launcher]
> > > > > I/am_task_to_front(   52): 3
> > > > > I/am_finish_activity(   52):
> > > > > [1129575992,3,com.cequint.cityid/.About,clear]
> > > > > I/am_destroy_activity(   52): [1129575992,3,com.cequint.cityid/.About]
> > > > > I/am_new_intent(   52):
>
> > > [1129518888,3,com.cequint.cityid/.UserLaunch,android.intent.action.MAIN,,,
> > > > > 274726912]
> > > > > I/am_on_paused_called(   94): com.android.launcher.Launcher
> > > > > I/am_resume_activity(   52):
> > > > > [1129749080,3,com.cequint.cityid/.UserLaunch]
> > > > > I/am_on_resume_called(  209): com.cequint.cityid.UserLaunch
> > > > > I/dvm_gc_madvise_info(   94): [290816,245760]
> > > > > I/dvm_gc_madvise_info(  209): [352256,241664]
> > > > > I/force_gc(   94): bg
>
> > > > > - John
> > > > > On Mar 25, 10:16 am, Dianne Hackborn <hack...@android.com> wrote:
> > > > > > You can do "adb logcat -b events" to see the event log which will
> > > include
> > > > > a
> > > > > > line the activity manager prints when finishing an activity, with 
> > > > > > the
> > > > > reason
> > > > > > why it is doing it.
>
> > > > > > On Tue, Mar 24, 2009 at 7:24 PM, jseghers <jsegh...@cequint.com>
> > > wrote:
>
> > > > > > > I am just starting on an Android app and I am puzzled about why my
> > > > > > > Task activity stack is being reset any time the application is
> > > > > > > launched from the Home screen.
>
> > > > > > > I used the ADT tools to create the application in Eclipse.
> > > > > > > The main activity is ".UserLaunch" and it starts the activity
> > > ".About"
> > > > > > > when the user presses a button.
> > > > > > > If the user then presses HOME and then relaunches the app,
> > > .UserLaunch
> > > > > > > is displayed and is the only thing on the stack.
>
> > > > > > > .UserLaunch has the launchMode singleTask. .About is standard.
> > > > > > > According to the documentation at
> > > > > > >http://developer.android.com/guide/topics/fundamentals.html#lmodes:
>
> > > > > > >    "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.) "
>
> > > > > > > The Task stack should be brought to the foreground and .About
> > > should
> > > > > > > still be displayed.
>
> > > > > > > I added Logging to all of the lifecycle events (edited to remove
> > > > > > > timestamps and shorten DEBUG/ and INFO/ to D/ and I/) and you can
> > > see
> > > > > > > that when HOME is pressed, .About cycles through onPause and 
> > > > > > > onStop
> > > > > > > (as expected).  Then when the app is again launched, .About is
> > > > > > > destroyed and .UserLaunch is restarted
>
> > > > > > > D/UserLaunch:(670): onCreate()
> > > > > > > D/UserLaunch:(670): onStart()
> > > > > > > D/UserLaunch:(670): onResume()
> > > > > > > I/ActivityManager(52): Displayed activity
> > > > > > > com.cequint.cityid/.UserLaunch: 4910 ms
> > > > > > > I/ActivityManager(52): Starting activity: Intent { comp=
> > > > > > > {com.cequint.cityid/com.cequint.cityid.About} }
> > > > > > > D/UserLaunch:(670): onPause()
> > > > > > > D/About(670): onCreate()
> > > > > > > D/About(670): onStart()
> > > > > > > D/About(670): onResume()
> > > > > > > I/ActivityManager(52): Displayed activity
> > > com.cequint.cityid/.About:
> > > > > > > 1031 ms
> > > > > > > D/UserLaunch:(670): onStop()
> > > > > > > I/ActivityManager(52): Starting activity: Intent
> > > > > > > { action=android.intent.action.MAIN categories=
> > > > > > > {android.intent.category.HOME} flags=0x10200000 comp=
> > > > > > > {com.android.launcher/com.android.launcher.Launcher} }
> > > > > > > D/About(670): onPause()
> > > > > > > D/About(670): onStop()
> > > > > > > D/dalvikvm(670): GC freed 413 objects / 34128 bytes in 72ms
> > > > > > > I/ActivityManager(52): Starting activity: Intent
> > > > > > > { action=android.intent.action.MAIN categories=
> > > > > > > {android.intent.category.LAUNCHER} flags=0x10200000 comp=
> > > > > > > {com.cequint.cityid/com.cequint.cityid.UserLaunch} }
> > > > > > > D/About(670): onDestroy()
> > > > > > > D/UserLaunch:(670): onRestart()
> > > > > > > D/UserLaunch:(670): onStart()
> > > > > > > D/UserLaunch:(670): onResume()
>
> > > > > > > Here is the relevant section of the Manifest:
>
> > > > > > > <application android:icon="@drawable/icon" android:label="@string/
> > > > > > > app_name">
> > > > > > >  <activity android:name=".UserLaunch"
> > > android:label="@string/app_name"
> > > > > > > android:launchMode="singleTask" >
> > > > > > >  <intent-filter>
> > > > > > >   <action android:name="android.intent.action.MAIN" />
> > > > > > >   <category android:name="android.intent.category.LAUNCHER" />
> > > > > > >  </intent-filter>
> > > > > > >  </activity>
> > > > > > >  <activity android:name=".About" android:launchMode="standard">
> > > > > > >  </activity>
> > > > > > > </application>
>
> > > > > > > Anyone have any ideas why this is always resetting the Activity
> > > Stack?
>
> > > > > > --
> > > > > > Dianne Hackborn
> > > > > > Android framework engineer
> > > > > > hack...@android.com
>
> > > > > > Note: please don't send private questions to me, as I don't have 
> > > > > > time
> > > to
> > > > > > provide private support.  All such questions should be posted on
> > > public
> > > > > > forums, where I and others can see and answer them.- Hide quoted 
> > > > > > text
> > > -
>
> > > > > > - Show quoted text -
>
> > > > --
> > > > Dianne Hackborn
> > > > Android framework engineer
> > > > hack...@android.com
>
> > > > Note: please don't send private questions to me, as I don't have time to
> > > > provide private support.  All such questions should be posted on public
> > > > forums, where I and others can see and answer them.- Hide quoted text -
>
> > > > - Show quoted text -
> > > --~--~---------~--~----~------------~-------~--~----~
> > > 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
> > > -~----------~----~----~----~------~----~------~--~---
>
> > --
> > Dianne Hackborn
> > Android framework engineer
> > hack...@android.com
>
> > 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 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