Skip to content

Commit

Permalink
Merge pull request leolin310148#72 from opayen/master
Browse files Browse the repository at this point in the history
Avoid crash if PackageManager returns bad package name or null
  • Loading branch information
leolin310148 committed Apr 21, 2016
2 parents 51e4aa1 + 769e945 commit 3751836
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,11 @@ public static void removeCountOrThrow(Context context) throws ShortcutBadgeExcep
}

private static void initBadger(Context context) {
sComponentName = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName()).getComponent();

Log.d(LOG_TAG, "Finding badger");

//find the home launcher Package
try {
sComponentName = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName()).getComponent();

Log.d(LOG_TAG, "Finding badger");
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
ResolveInfo resolveInfo = context.getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY);
Expand Down

0 comments on commit 3751836

Please sign in to comment.