Making a single-instance android app with Intents

If you have Intents that you want to react to in your android app, but you don’t want each new Intent to launch a new instance of your android app, you can make it single instance by adding the following to your main activity’s section in your AndroidManifest.xml:

  android:launchMode="singleInstance"

When you do this, instead of processing your intents in onCreate(), you process it in onNewIntent():

@Override
protected void onNewIntent(Intent intent) {
  // ... process the intent
}
Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *