1

An issue I was having with my app is that it wasn't resuming to the most recent activity. I added

android:alwaysRetainTaskState="true"

to AndroidManifest.xml. It fixed the issue for debug mode but not when I built for release mode. Kinda.

If I install the app via downloading the release APK to the phone's sdcard and installing from there the mentioned bug exists. If I install the exact same APK via adb the bug does not exist. This is true for both pre and post Android 4.0 devices.

Any ideas? Because I'm so lost.

bclymer
  • 6,679
  • 2
  • 27
  • 36
  • 2
    Do you start the app directly from the installer (after installation the installer asks if you want to start the app). If so, this is your problem. There is a nasty, long-standing bug that apps started by the installer are in a strange state. If you then use the HOME button to return to the HOME screen and then return to your app, Android happily launches the root activity of your app **again** :-( – David Wasser Jan 17 '13 at 23:35
  • does the mentioned behavior persist after a reboot? – sschrass Jan 17 '13 at 23:37
  • 1
    @DavidWasser you were right. That's very frustrating. Thank you! You can add an answer if you want and I will mark it correct. – bclymer Jan 22 '13 at 17:33
  • Added an answer. Glad to be of help. – David Wasser Jan 22 '13 at 18:23

1 Answers1

2

Do you start the app directly from the installer (after installation the installer asks if you want to start the app). If so, this is your problem. There is a nasty, long-standing bug that apps started by the installer are in a strange state. If you then use the HOME button to return to the HOME screen and then return to your app, Android happily launches the root activity of your app again :-(

For more details on this bug see http://code.google.com/p/android/issues/detail?id=26658 Many people have struggled for days chasing this problem :-( Please star the issue to raise awareness.

The bug is there on all devices, on all versions of Android (at least up to ICS, haven't tested on JellyBean yet). It all works as it should in the emulator, so you cannot use emulator behaviour as an indication of real device behaviour.

A simple workaround for this problem can be found at http://code.google.com/p/android/issues/detail?id=2373#c21

David Wasser
  • 93,459
  • 16
  • 209
  • 274