4

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

For Example: Notification like facebook, missed call and new message notification. I have attached sample screen shot here.

Danubian Sailor
  • 21,505
  • 37
  • 137
  • 211
Android_coder
  • 9,303
  • 2
  • 15
  • 23

2 Answers2

6

There is no general way for that, I guess there are some private extensions of the manufacturers. So you could dig for that device specific APIs, but they could been private too, better drop that idea.

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

Community
  • 1
  • 1
rekire
  • 45,039
  • 29
  • 149
  • 249
0

In android, we don't have badge style approach as iOS but some manufactures are supporting to display badge on app icons.

Example for badge style icon on app in android

Samsung , sony and HTC supports adding badge to the app icon.

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);

For 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);

for 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);
Harsha Vardhan
  • 3,286
  • 2
  • 15
  • 22