1

How to prevent multiple instances of an Activity, with back button?

view story
linux-howto

http://stackoverflow.com – I have an example app with one Activity. I'd like the user to be able to leave the app using the back button, and renter later via the app's icon without creating a new instance of the Activity. The problem is, if I press the back button and renter n times, then I end up with n instances of the app (as observed in the Memory Analysis Tool). I've tried overriding onBackPressed() to call finish(). In this case, I can see that onDestroy() is called, but it still leaves multiple instances of the Activity in memory. I've also tried the the different android:launchMode's, including "singleTop", (HowTos)