Solution:
If the same notification ID is used, how can I tell the notification handling activity and the content of each notification?
Pendingintent = pendingintent. getactivity (this, 0,
Intent, pendingintent. flag_update_current );
The last parameter ensures that the latest notification is displayed.
If different notification IDs are used, why is the intent of the first notification always obtained after the notification activity is processed?
Multiple intents are differentiated based on their data attributes. If the data is the same, they are considered to be the same intent.
It is not easy to use after practice. Ask someone to find a solution.
Pendingintent. getactivity (context, int requestcode, intent, int flags)
If the requestcode value is the same, multiple notifications will point to one intent.
The problem can be solved as long as the requestcode is different!
Paste a complete piece of code: After the download is complete, a notification is displayed in the notification bar.
/**
* Status Bar Message notification download complete
* @ Param Context
* @ Param name
*/
Public static void policytaskfinishtostatusbar (context, string name)
{
String text;
If (name! = NULL ){
TEXT = Name + context. getstring (R. String. has_download );
} Else {
TEXT = context. getstring (R. String. has_download );
}
Icationicationmanager nfm = (icationicationmanager) Context. getsystemservice (context. icationication_service );
Notification = new notification (R. drawable. Icon, text, system. currenttimemillis ());
Notification. Flags = notification. flag_auto_cancel; // click to automatically clear the notification.
Intent openintent = new intent ();
Openintent. setclass (context, mainactivity. Class );
Bundle DATA = new bundle ();
Data. putint (constants. boot_index_tag, mainactivity. downloadpageloadedstate );
Openintent. putextras (data );
Pendingintent contentintent = pendingintent. getactivity (context, 1, openintent, 0 );
Notification. setlatesteventinfo (context, context. getstring (R. String. qc_download_tip), text, contentintent );
Nfm. Y (constants. qc_download_notify, notification );
}