1.此功能是指應用圖標展現的數字,例如未讀短信,郵件,相似iOS應用iconjava
原生Android系統並不支持此功能android
定製的Samsung,sony支持此功能,有各自對應不一樣的實現方式,以三星爲例git
1.在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.查看你的APP是否已經註冊在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.若是沒有註冊就註冊上去: ContentValues cv = new ContentValues(); cv.put("package", getPackageName()); // Name of your activity declared in the manifest as android.intent.action.MAIN. // Must be fully qualified name as shown below cv.put("class", "com.example.badge.activity.Test"); cv.put("badgecount", 1); // integer count you want to display // Execute insert getContentResolver().insert(Uri.parse("content://com.sec.badge/apps"), cv); 4.若是已經註冊了就用下面方法更新角標: ContentValues cv = new ContentValues(); cv.put("badgecount", 0); getContentResolver().update(Uri.parse("content://com.sec.badge/apps"), cv, "package=?", new String[] {getPackageName()}); 附:BadgeProvider https://github.com/shafty023/SamsungBadger
參考http://blog.csdn.net/qq549631030/article/details/38512207github
2.對於應用view級別的數字提醒展現可使用開源控件app
https://github.com/jgilfelt/android-viewbadgeride