Since Launch on Boot was first published, a number of people have wanted a feature where an app launches on waking up. I have previously looked into the issue and believed it was not feasible. After Android Central’s post on the app, I was encouraged again to work on the feature. However, after a little more exploring, I have completed the feature and it is available in today’s app update.
The system sends out broadcasts to apps based on all kinds of events. One of which being
ACTION_SCREEN_ON , which is sent when the device becomes interactive again. This happens in a few ways, one of which is when the device is unlocked. Android TVs do not have lockscreens, so do not get unlocked, so does not receive this broadcast. This is where my original exploration ended.
But recently I had a new idea for how this could happen. If you have a screensaver setup for your TV, then the app can listen for the broadcast
ACTION_DREAMING_STOPPED which is sent when you exit the dream. This also indicates when you are resuming your device. In order for this listener to run, it requires a foreground service to constantly be ready to receive the broadcast. Foreground services are marked through a notification. This one should be low priority and be out of your way.
The app layout now has a new switch which lets you toggle whether to launch your app when the device boots or also when it wakes up.
You can download the app on Google Play or check out the source code on GitHub.