Search code examples
androidandroid-intentmanifestkiosk

Android Exit own Launcher App


I created a small custom Launcher App with setting

<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />

in my Android Manifest. But if I want to exit to the normal Launcher, how can I do this?


Solution

  • First clear defaults for you launcher using

    this.getPackageManager().clearPackagePreferredActivities(this.getPackageName());
    

    Then exit from your activity

    finish();
    

    Then simulate home button using below, it'll show the home selecter

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

    Good luck :)