Search code examples
androidroothomescreenkiosk-mode

How to directly boot your android app straight from splash screen, without showing the home screen?


I'm preparing an Android tablet to be part of a manufactured product. The tablet is turned into a dedicated tool to operate a machine, show some live data and move some files from the tablet to a phone via Bluetooth. For various reasons, including legacy, we want to stick to an Android tablet. I'm going to run the app in "kiosk" mode, which on itself isn't a problem at all. I even set up the app to catch the android.intent.action.BOOT_COMPLETED intent to auto-start the app.

The only problem is when rebooting the tablet, after it showed our custom boot-screen, it is briefly showing the home screen before starting our app, allowing users to intervene by starting other apps, changing Android system settings, etc. I would like to fix this by either extending the boot screen to last until the app has started, or to disable/remove the home screen from the tablet (preferred option).

I use a rooted device. Custom ROM would be an option if absolutely necessary but I prefer not to go down that path. I'm completely stuck at this point, any help/thoughts/options would be greatly appreciated.


Solution

  • In Android it is possible to create a launcher app. This can be used to customise the home-screen of an Android device. This app will replace your home-screen. In normal launcher-apps you want to implement behaviour to open other apps. But that isn't necessary in your case, since you want to create a kiosk app.

    For you it is as simple as adding these two lines into the intent-filter of your mainActivity:

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

    Your result will be something like this:

     <activity
            android:name=".MainActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
                <category android:name="android.intent.category.HOME" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
    

    When you press on the home-button you will get to choose the default launcher app. Mark your app as the default-launcher and it will replace the home-screen. You can also change your launcher-app in your device's settings.

    You might want to implement auto-restart as well, because if your launcher-apps crashes the user can choose which launcher-app he wants to use and can escape the kiosk-mode.