1. For the higher version of the SDK, (more than 16)
1 //High version of the notification bar, minimum requirements SDK version is2Notificationmanager nm =(Notificationmanager) Getsystemservice (notification_service);3 4 //chained programming, each return is a builder object5Notification Notification =NewNotification.builder ( This)6. Setcontenttitle ("title")7. Setcontenttext ("Content")8 . Setlargeicon (Bitmapfactory.decoderesource (Getresources (), r.drawable.ic_launcher))9 . Setsmallicon (R.drawable.ic_launcher)Ten . Build (); OneNm.notify (1, notification);
Display effect:
2. For the lower version of the SDK
1Notificationmanager nm =(Notificationmanager) Getsystemservice (notification_service);2 3 //The second parameter is: Flip the displayed text on the status bar4Notification Notification =NewNotification (R.drawable.ic_launcher, "come out?"), System.currenttimemillis ());5 6 //After you specify the click Notification, jump to an interface to call for example7Intent Intent =NewIntent ();8 intent.setaction (intent.action_call);9Intent.setdata (Uri.parse ("tel://110"));Ten One //Deferred Intent Object---used to describe what to do in the future APendingintent contentintent = pendingintent.getactivity ( This, 0, intent, 0); - - //set the drag notification down, the content of the display and the interface to jump to after clicking theNotification.setlatesteventinfo ( This, "title", "Content", contentintent); - -Nm.notify (1, notification);
Display effect:
Here I call after click for example
The code implementation of the Android phone dropdown status bar