Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to achieve push notification badge in android for all devices

I want to display push notification badge in all devices like Samsung,Sony,Lg etc., I want to display notification badge like facebook native application. i did small research for that in my result Android relies on the Notification Center to give the user indication about incoming events. So technically, if your app already does that, you don't have to do anything else. but some devices have own framework badge receivers.

In sony

http://marcusforsberg.net/blog/android-notification-badge-app-icon-sony/

Intent intent = new Intent();

intent.setAction("com.sonyericsson.home.action.UPDATE_BADGE");
intent.putExtra("com.sonyericsson.home.intent.extra.badge.ACTIVITY_NAME", "com.yourdomain.yourapp.MainActivity");
intent.putExtra("com.sonyericsson.home.intent.extra.badge.SHOW_MESSAGE", true);
intent.putExtra("com.sonyericsson.home.intent.extra.badge.MESSAGE", "99");
intent.putExtra("com.sonyericsson.home.intent.extra.badge.PACKAGE_NAME", "com.yourdomain.yourapp");

sendBroadcast(intent);

In Samsung

https://github.com/shafty023/SamsungBadger

Add the following permissions to your application's AndroidManifest.xml

uses-permission android:name="com.sec.android.provider.badge.permission.READ" 
uses-permission android:name="com.sec.android.provider.badge.permission.WRITE" 

To badge your icon with "1"

Context context = getApplicationContext();
if (Badge.isBadgingSupported(context)) {
    Badge badge = new Badge();
    badge.mPackage = context.getPackageName();
    badge.mClass = getClass().getName();
    badge.mBadgeCount = 1;
    badge.save(context);
}

Is there any other framework badge receivers code is available?

like image 943
prasad thangavel Avatar asked Oct 19 '25 08:10

prasad thangavel


1 Answers

I also faced same problem but perfect solution for your question is below link:

https://derivedcode.wordpress.com/2013/10/09/showing-badge-or-count-in-android-app-icon/

like image 155
androiddeveloper2011 Avatar answered Oct 20 '25 22:10

androiddeveloper2011