About Android Launchmode "singleTask"


Answer :

You sound right.

Why don't you test it.

There is also this app that can help explain launch mode:

https://play.google.com/store/apps/details?id=com.novoda.demos.activitylaunchmode

enter image description here

Sources are at https://github.com/gnorsilva/Activities-LaunchMode-demo


The ActivityC will be removed from task1 and ActivityB becomes the top Activity. 

Yes, you are Right...

ActivityC will be removed from i.e. the onDestroy method of the ActivityC will be called. Hence when the user launches Task 1 again, the ActivityB is shown rather than ActivityC.

Have created 2 Tasks (Projects) and uploaded the same @ SendSpace. Try it out...

If you look at androids documentation it says

" A "singleTask" activity allows other activities to be part of its task. It's always at the root of its task, but other activities (necessarily "standard" and "singleTop" activities) can be launched into that task."

This means that when you click the home button all the activities above the single-task activity (which in your case is ActivityB) are removed from the stack.

In the sample, the app's I had given you earlier if you just run the project "AndroidTest" and click the home button in the logs you can see that the 2nd Activity is put on Pause, and when you launch it again from the "Recent App's" list the 2nd Activity is Destroyed.

In a scenario where the Activity's above the Single Instance activities (ActivityB) are not removed from the Back Stack, and another application request this Activity (ActivityB) it may not be shown and the intent may be dropped. But this has extremely fewer chances of happening because the user will have to press the Home button and but the current Task\App in the BackStack before he could navigate to another Task\App.

Hence the warning

The other modes — singleTask and singleInstance — are not appropriate for most applications, since they result in an interaction model that is likely to be unfamiliar to users and is very different from most other applications.

I hope this solves your doubts.


Comments

Popular posts from this blog

Are Regular VACUUM ANALYZE Still Recommended Under 9.1?

Can Feynman Diagrams Be Used To Represent Any Perturbation Theory?