The code implementation of the Android phone dropdown status bar

Source: Internet
Author: User

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

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.