Reputation: 336
Seems that onNewIntent()
of my MainActivity is not being called when I have another Activity
on top of it, if I close the second Activity
it does get called just fine, it's like the other Activity
which is on top is blocking the messages? Both Activity
s are set to singleTop in the manifest and I set the Intent
from a notification:
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
intent.setAction(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
PendingIntent pIntent = PendingIntent.getActivity(getApplicationContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
Does anybody know what could be wrong?
Thanks!
Upvotes: 2
Views: 2840
Reputation: 49986
You have probably already searched google - there are lots of questions on why onNewIntent is not called.
It might depend on which android version you are doing tests, but you might try adding Intent.FLAG_ACTIVITY_SINGLE_TOP
flag to your intent - even though you have it in your manifest, together with Intent.FLAG_ACTIVITY_CLEAR_TOP
.
intent.setFlag(Intent.FLAG_ACTIVITY_SINGLE_TOP|Intent.FLAG_ACTIVITY_CLEAR_TOP);
this will remove activities above you activity which you want to launch.
But if your intent is to keep two activities alive, and switch between them, then look into android:taskAffinity and FLAG_ACTIVITY_NEW_TASK
.
Upvotes: 2
Reputation: 69218
Verify that the correct launch mode is set for the Activity receiving the Intent. Set launchMode
to "singleTop
" in their package, or if a client used the FLAG_ACTIVITY_SINGLE_TOP
flag when calling startActivity(Intent)
.
Upvotes: 1