1
    Intent intent = new Intent(_context, MainActivity.class);
    PendingIntent activity = PendingIntent.getActivity(_context, 0, intent, 0);
    notification.contentIntent = activity;

Enter MainActivity from notification if MainActivity is already opened, thus I need exit twice. Is this a falg problem, what should I do?

thecr0w
  • 2,148
  • 4
  • 33
  • 59

1 Answers1

2

Yes It is.. You have to add this flag to your pending Intent.

Intent intent = new Intent(_context, MainActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP|   Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent activity = PendingIntent.getActivity(_context, 0, intent, 0);

Taken form here,

https://stackoverflow.com/a/7308940/603744

Community
  • 1
  • 1
Andro Selva
  • 53,910
  • 52
  • 193
  • 240