How to get a notification in the corner of the program icon?

How to get a red Badge Notifications on Android like ios style

For example: Notification, such as facebook, missed call and new notification. I have attached a sample screen here.

+4
source share
2 answers

There is no general way for this, I think there are some private manufacturers extensions. So you could dig up devices for these APIs, but they could also be private, it’s better to abandon this idea.

Update: However, there is a solution for samsung devices, see this answer .

+6
source

iOS, .

Android

Samsung, Sony HTC .

Samsung:

ContentResolver localContentResolver = this.a.getContentResolver();
Uri localUri = Uri.parse("content://com.sec.badge/apps");

ContentValues localContentValues = new ContentValues();
localContentValues.put("package", PACKAGE NAME);
localContentValues.put("class", CLASS NAME);
localContentValues.put("badgecount", number);

update localContentResolver, if update fails then localContentResolver.insert(localUri, localContentValues);

Sony

Intent intent= new Intent("com.sonyericsson.home.action.UPDATE_BADGE");

intent.putExtra("com.sonyericsson.home.intent.extra.badge.ACTIVITY_NAME", Class Name);

intent.putExtra("com.sonyericsson.home.intent.extra.badge.SHOW_MESSAGE", true);

intent.putExtra("com.sonyericsson.home.intent.extra.badge.MESSAGE",number);

intent.putExtra("com.sonyericsson.home.intent.extra.badge.PACKAGE_NAME", packageName);

sendBroadcast(intent);

HTC:

Intent updateIntent = new Intent("com.htc.launcher.action.UPDATE_SHORTCUT");
updateIntent.putExtra("packagename", packageName);
updateIntent.putExtra("count", number);
this.sendBroadcast(updateIntent);

Intent setNotificationIntent = new Intent("com.htc.launcher.action.SET_NOTIFICATION");
ComponentName localComponentName = new ComponentName(packageName, className);
setNotificationIntent.putExtra("com.htc.launcher.extra.COMPONENT", localComponentName.flattenToShortString());
setNotificationIntent.putExtra("com.htc.launcher.extra.COUNT", number);
this.sendBroadcast(setNotificationIntent);
0

Source: https://habr.com/ru/post/1534963/


All Articles