ANDROID Notification Notification

Source: Internet
Author: User

Android Notification bar notification simple but use, effect like, nonsense don't say, code:

1 Private voidnotification () {2 Notification Notification;3         intnotification_id = 11;4 5         //getting objects through system services6Notificationmanager Notificationmanager =(Notificationmanager) Getsystemservice (notification_service);7         //Create a Notification object8Notification.builder Nbuider =NewNotification.builder (mainactivity. This);9         //the effect of setting notification is the default effectTen nbuider.setdefaults (notification.default_lights); One         //set the text that notification appears in the status bar for the first time ANbuider.setticker ("Tell you to go on a business trip!" "); -         //title -Nbuider.setcontenttitle ("Notifications"); the         //Small title -Nbuider.setcontenttitle ("That's it."); -         //Small title -Nbuider.setcontenttext ("Good"); +         //delay 0ms, then vibrate 500ms, delay 300ms, then vibrate 350ms.  -Nbuider.setvibrate (New Long[]{0,500,300,350}); +Nbuider.setsmallicon (R.DRAWABLE.E);//Do not set the icon does not come out, do not know what the situation A  at         //Create a intent pair image, as a pendingintent parameter -Intent Intent =NewIntent (mainactivity. This, Animationactivity.class); -         //activity associated with the Pendingintent object -pendingintent pi = pendingintent.getactivity (mainactivity. This, 0,intent,0); -  -  in         //Open Trigger - nbuider.setcontentintent (pi); to  +         //Create a notification -Notification =nbuider.build ();//API 16 or more to use theNotification.flags |= Notification.flag_auto_cancel;//The original text icon disappears after clicking the notification *         //Send Notifications $ notificationmanager.notify (notification_id,notification);Panax Notoginseng}

ANDROID Notification 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.