Skip to content Skip to sidebar Skip to footer

Android Multiple Instances

I am in a problem with the notifications in android, whenever I click the notification evrytime I have to call the same activity again, but as far as I am thinking the new activity

Solution 1:

Put the below code for that activity in maifest :

android:launchMode="singleTop"

Then for handling the new changes when the activity is called again, override the following method.

@OverrideprotectedvoidonNewIntent(Intent intent) {
    super.onNewIntent(intent);      
    //Do your new intent handling here.     
}

The code you put in manifest makes sure that only one instance of that activity is created. and you can handle the changes required on new intent in the onNewIntent overrided method in that activity.

Solution 2:

What about starting the activity in android:launchMode="singleInstance" mode or android:launchMode="singleTop" mode. I think this helps.

Solution 3:

Add to your calling intent

mIntent. setFlags (Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);

Add to the activity in menifest

android:launchMode="singleTop"

Post a Comment for "Android Multiple Instances"