Search code examples
androidstartuplaunching-application

Starting an app upon bootup


I'm writing an app for a specialized Android device that runs in a kiosk-like mode, i.e. my app will be the only app that runs, and must run upon startup.

Additionally, the app must launch only after the user has unlocked the device with a modified Android launcher.

I'm thinking about how to start the app in this case. Some thoughts:

  • Starting a service that receives the ACTION_BOOT_COMPLETED broadcast, and then having the service start the main app activity via an intent. My concern is that I'm not sure when exactly the ACTION_BOOT_COMPLETED broadcast occurs. I need the app to start only after the user unlocks the device, not before.
  • Modifying the launcher to start the app upon device unlock. Is this possible?

Are there any other intuitive ways to do what I've described?


Solution

  • Instead of starting the application on receiving the ACTION_BOOT_COMPLETED, register for another broadcast receiver ACTION_SCREEN_ON and ACTION_USER_PRESENT on boot complete dynamically, you cannot register this in Manifest file, on receiving the ACTION_USER_PRESENT just start your main activity.

    Here is the link for ACTION_SCREEN_ON example.