Hey! I was having exactly the same problem Rico described, as you can
see in my thread ( 
http://groups.google.com/group/android-developers/browse_thread/thread/76fa8600833f5348/59210de050c9bd20
).

After some investigation, I found that most launchers (including
Launchalot :P) start activities with FLAG_ACTIVITY_NEW_TASK and
FLAG_ACTIVITY_RESET_TASK_IF_NEEDED (some also set
FLAG_ACTIVITY_BROUGHT_TO_FRONT). The Android Market, however, only
sets FLAG_ACTIVITY_NEW_TASK, and I guess this is the reason for the
strange behavior.

This causes several OutOfMemoryErrors when my users upgrades the app
and launches it from the market. I couldn't use singleTask or
singleInstance as these flags mess up with the history. For example if
the activity stack is A -> B -> C and the user is in home screen,
pressing the application icon should take them back to activity C, but
setting singleTask or singleInstance on the main activity will
interfere with this.

In the end I found a workaround that prevents all those activities
from eating up all your memory. If you start all activities in your
app with the FLAG_ACTIVITY_CLEAR_TOP flag, you are guaranteed that no
activity will have more than one instance lying around in the stack.
For example if the stack is A -> B -> C -> A, and the user starts
activity B again, the OS will clear away the activities on the top and
you will end up with A -> B. Of course this only works if your
activities are designed to be single-instance.

Hope this helps.

On May 28, 7:09 am, Mark Murphy <[email protected]> wrote:
> Rico Yao wrote:
> > That app (Launchalot) is a launcher app (i.e. it just launches other
> > apps).  I'm not saying that Launchalot doesn't have multiple instances
> > of itself created if launched from the Market or notifications bar.  It
> > probably does.
>
> Anyone who puts Launchalot on the Market should have their head examined.
>
> :-)
>
> --
> Mark Murphy (a Commons 
> Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy
>
> _Android Programming Tutorials_ Version 2.0 Available!

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