Multiple notification conflicts in the android Status Bar

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.