views:

17

answers:

1

I have an application with two activities, A and B. A is the root activity, which then starts B.

When the stack looks like this:

HOME > A > B

...and I select A from the launcher, I want it to resume the task without clearing the stack, so B is shown. Right now this is mostly working.

However. In certain circumstances this occasionally does not work. What we see in this situation is that invoking A from the launcher will create a new instance of A and add it to our task's stack:

HOME > A > B > A

If we go back to home and select A again, we'll get another one:

HOME > A > B > A > A

...and so on.

This happens if, and only if, we uninstall the application completely using the application manager, and then reinstall it, via a file browser. Installing the application with adb does not cause this problem to appear.

In addition, when this problem manifests, if we then reboot the device, the problem goes away and everything starts behaving correctly!

This is smelling suspiciously like a launcher bug --- can anyone shed light on this?

This is using Eclair on real hardware (not the emulator).

Update

I have more information. It seems this is an Android core bug; see http://code.google.com/p/android/issues/detail?id=5277 in the Android bug tracker. Apparently running an application just after it's been installed by pressing the 'Run' button will run the application in a subtly wrong way.

It's also still extant on Froyo, not just Eclair.

Does anyone have any suggestions as to any possible workarounds?

+1  A: 

Check how I workarounded this - http://github.com/cleverua/android_startup_activity

Arhimed