I am trying to start an Activity A from a Notification Button (using PendingIntent). When I tap on this Notification Button and A is on top of history stack, it just not behave correctly:
What it should do:
- Activity A must duplicated on historystack, this way:
- When activity A is on top of history stack
Before:
[ A, ... old activities ... ]
After:
[ A, A, ... old activities ... ] - When activity A is not on top of history stack (default behavior)
Before:
[ B, ... old activities ... ]
After:
[ A, B, ... old activities ... ]
- When activity A is on top of history stack
What happens:
onCreate
is called, butgetIntent().getExtras()
isnull
.- Activity A is replaced and not recreated (I want a duplicate).
I've tried a lot of things: Intent.FLAG*
and PendingIntent.FLAG*
also, but unsuccessfully.
Edit 1: I tried these constants:
Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK
Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP
(but I don't want to clear top)
Code (part):
Intent intentCancel = new Intent(getApplicationContext(), ChallengeProposalActivity.class);
//intent.setAction(String.valueOf(System.currentTimeMillis()));
//intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
intent.putExtra(ChallengeProposal.NAME, proposal);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intentCancel, 0);
Code (full): http://pastebin.com/vNuEkBvi
What should I do?
Related questions:
PendingIntent not working when adding extras in intent
Duplicate MainActivity When Enter From Notification