Android, Get The Location When The Screen Is Off
Solution 1:
I'm not sure I have your answer but since you're 9 days in with nothing I'll give some suggestions.
My app is doing what you would like to do. I use a long running started Service to keep location updated even when the phone is off.
The difference most likely to cause different behavior between your code & mine is the return from onStartCommand()
. You are returning START_STICKY
. This is the recommended return for something like this:
This mode makes sense for things that will be explicitly started and stopped to run for arbitrary periods of time, such as a service performing background music playback.
However, I'm sending info in the Intent
that I needed to have redelivered so I'm returning START_REDELIVER_INTENT
. Try this (even if you have no need to redeliver any data) to see if it fixes your problem.
Also, I didn't need WakeLock
in my implementation. Maybe your implementation needs this though. Have you tried without it?
Edit: Lastly, what kind of device are you using? link
Post a Comment for "Android, Get The Location When The Screen Is Off"