Reputation: 369
I am opening an activity on clicking notification, that is working fine. But if that activity (which I am opening on clicking notification) is already open (user has opened it) then I want to close it before opening it as a result of clicking notification. So how can I do that. Please help.
Code:
Intent intent = new Intent(context, ViewReminders.class);
intent.putExtra("CALLER","GenNot");
intent.putExtra("ID",notification_id);
PendingIntent pIntent = PendingIntent.getActivity(context, 0, intent, 0);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context);
Upvotes: 0
Views: 1011
Reputation: 4959
Try with setting the following flags
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
Upvotes: 2