Background: You can start a message notification with activity and service, the difference being that one is triggered in the foreground and one is the background service.
To use message notifications, you must use two classes: NotificationmanagerAnd Notification, other notificationmanager are initialized with the Getsystemservice method, and the Notify method is used to send Message bar notifications and displays to the Android system.
Effect:
Code:
Copy Code code as follows:
Message Notification Bar
Define Notificationmanager
String ns = Context.notification_service;
Notificationmanager Mnotificationmanager = (notificationmanager) getsystemservice (NS);
Define the content information displayed by the notification bar
int icon = R.drawable.icon;
Charsequence Tickertext = "My notice bar title";
Long when = System.currenttimemillis ();
Notification Notification = new Notification (icon, Tickertext, when);
Define the content information to be displayed when the DROP-DOWN notification bar is defined
Context context = Getapplicationcontext ();
Charsequence Contenttitle = "My notice bar expands title";
Charsequence ContentText = "My notice bar expands the details";
Intent notificationintent = new Intent (this, bootstartdemo.class);
Pendingintent contentintent = pendingintent.getactivity (this, 0,
Notificationintent, 0);
Notification.setlatesteventinfo (context, Contenttitle, ContentText,
Contentintent);
Notifies the user to generate a title bar message notification using the Mnotificationmanager notify method
Mnotificationmanager.notify (1, notification);