Question

I have succeeded in launching the default home launcher through the following code while working with the emulator:

Intent de_intent=new Intent();
de_intent.setClassName("com.android.launcher","com.android.launcher2.Launcher");
startActivity(de_intent);

But when I am executing this code in the real device, it is showing following exception:

Unable to find explicit activity class {com.android.launcher/com.android.launcher2.Launcher} have you declared this in AndroidManifest.xml

Can anybody help me to solve this issue?

Was it helpful?

Solution 2

try following:

 Intent startMain = new Intent(Intent.ACTION_MAIN);
        startMain.addCategory(Intent.CATEGORY_HOME);
        startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(startMain);

OTHER TIPS

Do you have a Samsung device? They replaced the default Android launcher with their TouchWiz Home launcher. The following code worked for me using the setClassName() method:

Intent intent = new Intent(Intent.ACTION_MAIN);
        intent.setClassName("com.sec.android.app.launcher", "com.android.launcher2.Launcher");
        startActivity(intent);

If you want to return to HOME, you can use:

Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
startActivity(intent);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top