开发者

Accelerometer onSensorChanged not called when screen is off

开发者 https://www.devze.com 2023-02-24 17:22 出处:网络
I have a background service which is running all the times and collects sensor data. But when the screen dims, it stops collecting the data.

I have a background service which is running all the times and collects sensor data. But when the screen dims, it stops collecting the data.

I want it to collect even in this case.

My device is HTC MyTouch. I have tried prtial wake lock, buy it didn't work.

Can anyone please help me fix this proble开发者_运维问答m.

Thanks Sowmya


This is a documented issue: http://code.google.com/p/android/issues/detail?id=3708

Unfortunately no easy fix exists and the workarounds also don't always work. It seems to be fixed in Android 2.3.3 for most (if not all) devices though.


try this in oncreate method getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
this works in my app

0

精彩评论

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