Reputation: 1
I want my app to keep running when the screen is blank and locked.
This is an instrumentation app that runs when the phone is in the pocket, so we can blank the screen to save power.
Currently:
If the phone locks automatically the screen goes blank and the app terminates. When the phone is unlocked the app needs to be re-started.
If the phone is manually locked (with a tap on the power button) the screen goes blank, the app stays running, but the data to voice output stops "working". When the phone is unlocked the app is still running and the data to voice starts "working" again.
I don't think WakeLock will do that for me. It's a function that's more like a sticky bit, as in load and don't terminate unless there is a specif command to terminate.
Any pointers to what I should be doing would be appreciated - thanks - Rob
Upvotes: 0
Views: 6256
Reputation: 76466
Why don't you start a 'Service' that your Activity's can bind to. This can run even when your App isn't.
http://developer.android.com/reference/android/app/Service.html
A Service is an application component representing either an application's desire to perform a longer-running operation while not interacting with the user or to supply functionality for other applications to use.
Imagine how a mp3 playing application works, same scenario.
Upvotes: 1