Created
May 30, 2012 12:56
-
-
Save tai2/2836138 to your computer and use it in GitHub Desktop.
Test wheter an activity is the main or not.
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
private boolean isMain() { | |
boolean result = false; | |
Intent intent = getPackageManager().getLaunchIntentForPackage(getPackageName()); | |
List<ResolveInfo> info = getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); | |
if (!info.isEmpty()) { | |
result = info.get(0).activityInfo.name.equals(getComponentName().getClassName()); | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment