How to get the intent extras if the activity is `singleTask`?
Try setting the launchMode type of your MyActivity
as singleTop and then override the following method to look for the new intent:
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
//now getIntent() should always return the last received intent
}
If you must have single Task then use these flags for your intent:
resultIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK |Intent.FLAG_ACTIVITY_CLEAR_TASK);
if you use PendingIntent so also: PendingIntent.FLAG_CANCEL_CURRENT :
pIntent = PendingIntent.getActivity(context, 0, resultIntent, PendingIntent.FLAG_CANCEL_CURRENT );
(also use onNewIntent
in your activity to handle the extras.)