Search code examples
androidandroid-activitylauncherhomescreen

How to redirect User to default launcher in an android app?


It's been now a long time since I try to figure out how to develop a android unlock screen app working with an NFC authentication. I am working with a Nexus S. After several researches on the Internet, I came to the conclusion that replacing the lock screen as a third party app is just not supported right now and that we need to modify the platform to do a decent implementation.

This is the reason why I developed an home screen app that give the illusion of an unlockscreen app. But my problem is that I would like to be redirect to the default laucher at the end of the procedure.

I first tried with the code below but the problem is that I will have the choice between the default home screen and my new app

Intent goHome = new Intent();
i.setAction("android.intent.action.MAIN");
i.addCategory("android.intent.category.HOME");
startActivity(goHome);

So I then I tried with the code below but it doesn't seem to work.

Intent goHome = new Intent(Intent.ACTION_MAIN);
goHome.setClassName("com.android.launcher", "com.android.launcher.Launcher");
startActivity(goHome);

I get the following logCat

Unable to find explicit activity class ( com.android.launcher.laucher)

Do you have any idea why it doesn't work? Is it the right way of doing it?


Solution

  • try this :

    goHome.setClassName("com.android.launcher", "com.android.launcher2.Launcher");