Notification is commonly used in pull-down message pushes.
The composition of the notification
Examples of nitification
1. Create a new builder to select the Notification.compat package.
2. Then use Builder to set the properties of the nitification.
Code:
Public class mainactivity extends Activity { Public Static Final intnotification_id = $;intCount =0;@Override protected void onCreate(Bundle savedinstancestate) {Super. OnCreate (Savedinstancestate); Setcontentview (R.layout.activity_main); Findviewbyid (R.id.button1). Setonclicklistener (NewOnclicklistener () {@Override Public void OnClick(View v) {//TODO auto-generated method stubcount++; Builder Builder =NewNotificationcompat.builder (mainactivity. This); Builder.setsmallicon (R.drawable.ic_launcher); Builder.setcontenttitle ("Oh, wow!" You have the message of Count's heart.); Builder.setcontenttext ("Notification created successfully"); Notification Notification = Builder.build (); Notificationmanager manager = (Notificationmanager) getsystemservice (Context.notification_service); Manager.notify (notification_id, NOTIFICATION); } }); }}
NOTIFICATION_ID This constant value is used to uniquely identify the NOTIFICATION.
This notification can be updated directly with each update. Builder can set more properties.
Android Notification-android Learning Journey (ii)