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?
Yes It is.. You have to add this flag to your pending Intent.
Taken form here,
https://stackoverflow.com/a/7308940/603744