Android app icon Upper right corner unread message number hint

Source: Internet
Author: User

1. This function refers to the number displayed by the app icon, such as an unread text message, an email, an icon similar to an iOS app

Native Android system does not support this feature

Customized Samsung,sony support this feature, with each corresponding to different implementations, take Samsung as an example

1. Add two permissions in Androidmanifest.xml: <uses-permission android:name= "Com.sec.android.provider.badge.permission.READ" /><uses-permission android:name= "Com.sec.android.provider.badge.permission.WRITE"/>2. Check to see if your app is registered in Badgeprovider: URI uri = uri.parse ("Content://com.sec.badge/apps"); Cursor C = getcontentresolver (). Query (URI, NULL, NULL, NULL, NULL), if (c = = null) {return;}    try {if (!c.movetofirst ()) {return;    } c.movetoposition (-1);        while (C.movetonext ()) {String pkg = c.getstring (1);        String clazz = c.getstring (2);        int badgecount = C.getint (3);    LOG.D ("Badgetest", "Package:" + pkg + ", class:" + Clazz + ", Count:" + string.valueof (CNT)); }} finally {C.close ();} 3. Register if not registered: contentvalues CV = new Contentvalues () cv.put ("Package", Getpackagename ());//Name of your activity Declared in the manifest as android.intent.action.main.//must is fully qualified name as shown Belowcv.put ("Class", "com. Example.badge.activity.Test ");Cv.put ("Badgecount", 1); Integer count you want to display//Execute insertgetcontentresolver (). Insert (Uri.parse ("content://com.sec.badge/ Apps "), CV), 4. If you have already registered, use the following method to update the corner label: contentvalues CV = new Contentvalues (), Cv.put (" Badgecount ", 0); Getcontentresolver (). Update (Uri.parse ("Content://com.sec.badge/apps"), CV, "Package=?", new string[] {getpackagename ()}); Attached: Badgeprovider Https://github.com/shafty023/SamsungBadger

Reference http://blog.csdn.net/qq549631030/article/details/38512207

2. Open source controls are available for digital reminder displays that apply view levels

Https://github.com/jgilfelt/android-viewbadger

Android app icon Upper right corner unread message number hint

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.