What am I missing here?
Problem is, I launch my app onCreate is called. I press the home button to leave it, press the app icon again and onCreate is called yet again. The activity is being killed, right? Well, if I press home to leave the app, hold down home, then pick the app from the running apps it resumes where I left off. So hitting home within the app is not killing the activity. Press the button to open the app is killing the activity.
I use Eclipse. I just downloaded the latest Eclipse and re-downloaded ADT and updated the Android SDK. Everything is up-to-date. I even uninstalled all java and downloaded and re-installed the latest jdk and runtime on my computer. Then re-signed the app.
Using Eclipse I added the skeleton sample project. Signed in debug mode and it resumes every single time, just like my real app. Signed for release and it has the problem: press home to leave the app, press the icon to launch the app and onCreate is called again. Literally every single time. Shouldn't it be resuming?
The problem is it's not just me (I have a BIONIC). It happens on other peoples phones and it happens on the emulator, but it only happens when signed for release. Signed for debug and it's perfectly fine.
Any ideas on this?
According to this previous question you need to set the FLAG_ACTIVITY_REORDER_TO_FRONT flag using setFlags(). This would cause your running activity to be reused instead of recreated every time an application starts it. When you press the icon on the home button, the activity is started. The home screen doesn't know if the application is running or not, so it just starts it. When you long press home, it actually switches to the activity as it knows it's running.
Another option seems to be setting android:launchMode to
singleTop
.