Ensure Only One Activity Is Created

I found that when my application is pushed into the background (via, say, pressing the Home button) and then resumed, a new activity is created. In order to ensure that the original activity is preserved, add this to the activity tag in the Android manifest:

android:launchMode="singleTask"

A key benefit of the above is that if applied to the root activity of your app, you can jump to the “home” screen by starting the root activity. All the other activities above it are popped off the stack and destroyed.

Advertisements
Published in: on January 18, 2012 at 5:26 pm  Leave a Comment  

The URI to TrackBack this entry is: https://sestoelemento.wordpress.com/2012/01/18/ensure-only-one-activity-is-created/trackback/

RSS feed for comments on this post.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: