Ah the problem is that you want to put singleTask on what you have -published- as your main activity, which is the splash screen. This is the thing that the use launches from home. What has happened is: 1. Splash screen launched into its own task. 2. Main activity launched into its own task. 3. Splash screen exits. 4. User launches app again, which is the splash screen activity. 5. The splash screen activity has the same task affinity is the currently running main activity, so the system brings the current main activity to the foreground and launches the splash screen on top of it.
So make your splash screen singleTask instead of the "main" activity which is really inside of your app's task flow, and all should be fine. (Or don't use singleTask at all. Is there a reason you are using? Very few apps actually do want it, and unless your app is designed to be launched by other apps in special ways, there is almost certainly no reason to use it at all.) On Thu, Sep 17, 2009 at 1:29 AM, RickardF <[email protected]>wrote: > > Thanks for your response. I've browsed this group and it seems the > "launchMode" settings have caused a little confusion at times. This is > also valid for me, I'm afraid... > > Anyway, I have pasted an excerpt from the output of "adb shell dumpsys > activity" (sorry for the mass of text) for the situation where I have > one application with two activities; SplashScreen (launchMode normal) > and mainActivity (launchMode singleTask). I have started the > application from the launcher which starts the SplashScreen activity. > From there the mainActivity is started with: > Intent intent = new Intent(SplashScreen.this, > com.rick.myApp.MainActivity.class); > SplashScreen.this.startActivity(intent); > > To me, the dump indicates that Task11 contains two activities where > SplashScreen is at the front of the task (root?) and MainActivity is > not at the top of the stack. When we know that MainActivity has > launchMode=singleTask, doesn't the dump contradict the documentation > in the sense that it is not at the root? > > Thanks for helping me understand this. > > /Rickard > > > DUMP OF SERVICE activity: > > Activities in Current Activity Manager State: > > Task{11 com.rick} > > clearOnBackground=false numActivities=2 rootWasReset=false > > affinity=com.rick > > intent=Intent { flags=0x10000000 comp={com.rick/ > com.rick.ui.activity.SplashScreen} } > > affinityIntent=null > > origActivity=null > > lastActiveTime=68582390 (inactive for 9s) > > History #5: > > HistoryRecord{4360d2d0 {com.rick/com.rick.myapp.MainActivity}} > > packageName=com.rick processName=com.rick > > launchedFromUid=10018 app=ProcessRecord{437381f0 1106:com.rick/ > 10018} > > Intent { comp={com.rick/com.rick.myapp.MainActivity} } > > frontOfTask=false task=Task{11 com.rick} > > taskAffinity=com.rick > > realActivity=ComponentInfo{com.rick/ > com.rick.myapp.MainActivity} > > dir=/data/app/com.rick.apk res=/data/app/com.rick.apk data=/ > data/data/com.rick > > labelRes=0x7f080005 icon=0x7f020004 theme=0x1030006 > > stateNotNeeded=false componentSpecified=true > isHomeActivity=false > > configuration={ scale=1.0 imsi=310/260 locale=en_US touch=3 > key=2/1/2 nav=3 orien=1 } > > resultTo=null resultWho=null resultCode=-1 > > results=null > > pendingResults=null > > readUriPermissions=null > > writeUriPermissions=null > > launchFailed=false haveState=false icicle=null > > state=RESUMED stopped=false finishing=false > > keysPaused=false inHistory=true persistent=false launchMode=2 > > fullscreen=true visible=true frozenBeforeDestroy=false > thumbnailNeeded=false idle=true > > waitingVisible=false nowVisible=true > > configDestroy=false configChangeFlags=0 > > connections=null > > History #4: > > HistoryRecord{435db2f0 {com.rick/ > com.rick.ui.activity.SplashScreen}} > > packageName=com.rick processName=com.rick > > launchedFromUid=-1 app=ProcessRecord{437381f0 1106:com.rick/ > 10018} > > Intent { flags=0x10000000 comp={com.rick/ > com.rick.ui.activity.SplashScreen} } > > frontOfTask=true task=Task{11 com.rick} > > taskAffinity=com.rick > > realActivity=ComponentInfo{com.rick/ > com.rick.ui.activity.SplashScreen} > > dir=/data/app/com.rick.apk res=/data/app/com.rick.apk data=/ > data/data/com.rick > > labelRes=0x7f080005 icon=0x7f020004 theme=0x1030006 > > stateNotNeeded=false componentSpecified=true > isHomeActivity=false > > configuration={ scale=1.0 imsi=310/260 locale=en_US touch=3 > key=2/1/2 nav=3 orien=1 } > > resultTo=null resultWho=null resultCode=0 > > results=null > > pendingResults=null > > readUriPermissions=null > > writeUriPermissions=null > > launchFailed=false haveState=true icicle=Bundle > [mParcelledData.dataSize=364] > > state=STOPPED stopped=true finishing=false > > keysPaused=false inHistory=true persistent=false launchMode=0 > > fullscreen=true visible=false frozenBeforeDestroy=false > thumbnailNeeded=false idle=true > > waitingVisible=false nowVisible=false > > configDestroy=false configChangeFlags=0 > > connections=null > > Task{2 com.android.launcher} ........ > > > On 16 Sep, 18:41, Dianne Hackborn <[email protected]> wrote: > > Very much by definition, a single ask activity is always at the root of a > > stack. Anyone who launches that activity is forced to launch a new task, > so > > the activity can't be anything but the start of a new task. > > I don't know enough about what you are doing or seeing to help any more, > but > > there really should be no way to have such an activity embedded inside of > a > > task. > > > > On Wed, Sep 16, 2009 at 12:53 AM, RickardF <[email protected] > >wrote: > > > > > > > > > > > > > Hi all, > > > In the documentation (http://developer.android.com/guide/topics/ > > > manifest/activity-element.html#lmode) it is stated that an activity > > > with launchMode="singleTask" is always at the root of the sctivity > > > stack. However, when I run my "singleTask" activity for a few > > > scenarios and monitors behaviour with "adb shell dumpsys activity" I > > > can see it placed both at the top of the stack (with numActivities=2) > > > and in the middle of the stack (with numActivities=3). > > > The activity at the root (frontOfTask=True) has a "normal" launchMode. > > > > > Is the documentation incorrect or am I missing something? > > > > > Thanks, > > > Rickard > > > > -- > > 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. > > > -- 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 -~----------~----~----~----~------~----~------~--~---

