Skip to content

Instantly share code, notes, and snippets.

@tai2
Created May 30, 2012 12:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tai2/2836138 to your computer and use it in GitHub Desktop.
Save tai2/2836138 to your computer and use it in GitHub Desktop.
Test wheter an activity is the main or not.
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