方法一:
boolean isMyLauncherDefault() { final IntentFilter filter = new IntentFilter(Intent.ACTION_MAIN); filter.addCategory(Intent.CATEGORY_HOME); List<IntentFilter> filters = new ArrayList<IntentFilter>(); filters.add(filter); final String myPackageName = getPackageName(); List<ComponentName> activities = new ArrayList<ComponentName>(); final PackageManager packageManager = (PackageManager) getPackageManager(); // You can use name of your package here as third argument packageManager.getPreferredActivities(filters, activities, null); for (ComponentName activity : activities) { if (myPackageName.equals(activity.getPackageName())) { return true; } } return false; }
方法二
public boolean isMyAppLauncherDefault() { IntentFilter filter = new IntentFilter(Intent.ACTION_MAIN); filter.addCategory(Intent.CATEGORY_HOME); List<IntentFilter> filters = new ArrayList<IntentFilter>(); filters.add(filter); // the packageName of your application String packageName = getPackageName(); List<ComponentName> preferredActivities = new ArrayList<ComponentName>(); final PackageManager packageManager = (PackageManager) getPackageManager(); // You can use name of your package here as third argument packageManager.getPreferredActivities(filters, preferredActivities, packageName); if (preferredActivities != null && preferredActivities.size()> 0) { return true; } return false; }
http://www.android-ios-tutorials.com/225/get-default-launcher-pogrammatically-android/
http://*.com/questions/10188954/start-launcher-selection-programmatically-android