Problem with sensors in a service
i've a foreground service that read Accelerometer and Orientation sensors, and send a sms when the phone it's moved.
It works fine when the display is turned on, but when not it not works or it send the sms after lot of ti开发者_开发百科mes.
There is a broadcastreceiver in the service for reading incoming sms that works fine, if i send the command "status" its reply correctly.
What's the problem?
Thanks!
You need to acquire a wake lock to continue receiving sensor events.
http://developer.android.com/reference/android/os/PowerManager.html
I suggest a partial wake lock.
精彩评论