Home > DeveloperSection > Forums > When notification item is clicked from status bar clear the back stack activity?
Ankita Pandey
Ankita Pandey

Total Post:183

Posted on    October-14-2014 12:17 AM

 Android Android  Mobile Development 

 1 Reply(s)
 768  View(s)
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.

Kamlakar Singh
Kamlakar Singh

Total Post:194

Posted on    October-14-2014 12:25 AM

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);

Don't want to miss updates? Please click the below button!

Follow MindStick