2

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?

Stewbob
  • 16,759
  • 9
  • 63
  • 107
user1118764
  • 9,255
  • 18
  • 61
  • 113

2 Answers2

0

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.

Vignesh
  • 3,571
  • 6
  • 28
  • 44
  • Hi, thanks. Won't I need ACTION_BOOT_COMPLETED to start UpdateService? I tried the code, but the service never starts upon bootup and upon screen on, so I'm not receiving any broadcasts in my broadcast receiver. Also, won't this trigger every time the user unlocks the device, i.e. my app will run every time the user unlocks the device. – user1118764 Apr 11 '12 at 06:26
  • Once you receive the ACTION_SCREEN_ON for the first time unregister the same. – Vignesh Apr 11 '12 at 06:33
  • I tried calling UpdateService from a BootUpReceiver that receives ACTION_BOOT_COMPLETED and that works. However, it seems that ACTION_SCREEN_ON and ACTION_SCREEN_OFF literally means that the screen is either physical on, or off. It doesn't record the lock/unlock state of the phone. That's really what I'm after. – user1118764 Apr 11 '12 at 06:37
  • Have look at this [link](http://stackoverflow.com/questions/9747564/activity-handle-when-screen-unlocked), it may help you. – Vignesh Apr 11 '12 at 07:03
0

Both the cases are possible, we have listener for both the case, while rebooting the application you can use Action_Boot_completed. and for unlocking the screen, do follow the guidance from lock and unlock . Hope this will help you. Regards: HariramLakshmiNarayanan.

RAAAAM
  • 3,378
  • 19
  • 59
  • 108