문제

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