After spending about 8 hours yesterday on trying to resolve an eccentric behavior, I finally ended up realizing that its the property/issue/bug of the APK installer of Android 2.2 in my device and after performing the same test on about 5 different apps, I concluded that this was definitely not the issue with my app, but with either the device(HTC Desire) or droid 2.2. Still have to test it on other devices(as soon as I get my hands on one).
It goes on something like this, and the steps could be followed for installing any application.
Install the app from any source (market/sdcard/download from site).
When the installation is complete, it shows the dialog which says ‘Installation Complete’ and you have and option to ‘Open’ the app or ‘Ok’ to return to home or wherever you came from.
At this point, press ‘Open’ to (obviously) open the app. Now you have the home screen of the app.
Press your ‘Home’ key to return to the android home screen. Now the app you just opened should be running in background.
Now go to the applications menu and click the launcher (icon) of this very app which you installed. This is where the issue starts
What happens now is that android creates a NEW INSTANCE of the launcher of this app, ON TOP of the already existing stack.
You can again click on the ‘Home’ button to go to android home, and launch this very app and it will be started on the top of the second one, which is running on top of first one.
So if you have an app with activities A, B and C, and you launch that app after installing it directly, then A will be pushed on stack. If A launches activity B, then B is also pushed. So the backstack is now A–> B(top).
Now if the app is launched again from app menu, activity A is again pushed on top of the previous stack which now becomes A–>B–>A(top). This behavior is consistent and you can actually have ANY number of instances of the same app, one stacked over the other. I tested it by installing different apps, from sdcard, downloading them and from app market, each showing this behavior and had 6 instances in one case while testing, in which the backstack became A–>B–>A–>A–>A–>A–>A(top).
Things work just fine once you quit the initial activity on the stack by pressing ‘Back’ till you empty the stack or following application flow which might do so. This is just one time issue, which occurs when the app is launched directly from the installer after the installation is complete.
Let me know if you also have encountered this issue of have been able to reproduce it.