开发者

Problem with sensors in a service

开发者 https://www.devze.com 2023-02-22 19:28 出处:网络
i\'ve a foreground service that read Accelerometer and Orientation sensors, and send a sms when the phone it\'s moved.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号