Reputation: 788
I am developing an application my requirement is to finish my custom launcher and switch to default launcher. How can I achieve that?
Upvotes: 0
Views: 862
Reputation: 2577
follow the following steps:
By using Package Manager get the intents which is having launcher and category home. By using queryIntents method.
Use the 0th indexed intent and get the class name and package name. store some where else like sharedPreferences.
whenever you want to launch the default launcher just create intent with class name and packager name.
Then start that activity when it is required.
Following code may help you:
PackageManager packageManager = getPackageManager();
Intent i = new Intent();
i.addCategory(Intent.CATEGORY_HOME);
i.setAction(Intent.ACTION_MAIN);
List<ResolveInfo> queryIntentActivities = packageManager
.queryIntentActivities(i, 0);
ResolveInfo resolveInfo = queryIntentActivities.get(0);
String packageName = resolveInfo.resolvePackageName;
String className = resolveInfo.activityInfo.targetActivity;
Upvotes: 0