As my first Android app, I'm programming a kiosk for a working use. This app is set as default launcher and full-screen, so, when the tablet boot, the kiosk is already started and the user can't open other apps or escape from the kiosk app.

The last thing I'm not able to code is the ability to change from my kiosk/launcher to the default Android Launcher. I've prepared a password input: if the password is right, I would like to launch the Launcher.

This is what I have so far:

if (message.equals("password")) {
    Intent intent = new Intent("android.intent.action.MAIN");
    intent.addCategory("android.intent.category.HOME");
    startActivity(Intent.createChooser(intent, "Scegli:"));
}

I've tried this app only in the Android Studio's emulator, where the default launcher is the Android Launcher: with these instructions, the app simply goes on the default Android Launcher. So I suppose that, on the tablet, despite the createChooser, I only reach the default launcher, that will be my kiosk.

有帮助吗?

解决方案 2

Try setting your Intent like this:

intent.setAction(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);

其他提示

This is the OP's solution, migrated here from the question body

if (message.equals("password")) {
    getPackageManager().clearPackagePreferredActivities(getPackageName());
    final Intent intent = new Intent();
    intent.setAction(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_HOME);
    startActivity(intent);
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top