WHEN NOTIFICATION ITEM IS CLICKED FROM STATUS BAR CLEAR THE BACK STACK ACTIVITY?

Ankita Pandey

Total Post:183

Points:1285
Posted by  Ankita Pandey
 790  View(s)
Ratings:
Rate this:
I am working on a chat project. When a push notification is being received from GCM, i need to navigate to the chat contact list and clear the previously opened activity of my application.
  1. Kamlakar Singh

    Post:194

    Points:1396
    Re: When notification item is clicked from status bar clear the back stack activity?

    yes i have read and found the solution
        while passing the pending intent in GCMIntent Service, it is necessary to set flag for intent.
    I have mentioned the codes below. Please make use of it if anyone struggling with this concept
                PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
                        new Intent(this, MainActivity.class).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | 
                                Intent.FLAG_ACTIVITY_CLEAR_TASK), 0);

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!