Created
August 12, 2015 13:48
-
-
Save kmansoft/06a1aee4285ba95aa263 to your computer and use it in GitHub Desktop.
"Unread count" for Samsung and LG TouchWiz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SamsungLGLauncher { | |
private static final String TAG = "SamsungLGLauncher"; | |
private static final String SEC_PACKAGE_NAME = "com.sec.android.app.launcher"; | |
private static final String LG_PACKAGE_NAME = "com.lge.launcher2"; | |
private static final String ACTION = "android.intent.action.BADGE_COUNT_UPDATE"; | |
public static boolean isSamsungInstalled(Context context) { | |
return SystemUtil.isPackageInstalled(context, SEC_PACKAGE_NAME); | |
} | |
public static boolean isInstalled(Context context) { | |
if (SystemUtil.isPackageInstalled(context, SEC_PACKAGE_NAME) | |
|| SystemUtil.isPackageInstalled(context, LG_PACKAGE_NAME)) { | |
MyLog.i(TAG, "Samsung or LG launcher found"); | |
return true; | |
} | |
return false; | |
} | |
public static void sendTotalUnreadCount(Context context, int count) { | |
MyLog.i(TAG, "Sending unread count: %d", count); | |
try { | |
Intent intent = new Intent(ACTION); | |
intent.putExtra("badge_count", count); | |
intent.putExtra("badge_count_package_name", context.getPackageName()); | |
intent.putExtra("badge_count_class_name", "org.kman.AquaMail.ui.AccountListActivity"); | |
context.sendBroadcast(intent); | |
} catch (Exception x) { | |
// Ignore | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment