Accelerometer onSensorChanged not called when screen is off

左心房为你撑大大i 提交于 2019-12-13 02:41:46

问题


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 problem.

Thanks Sowmya


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/5671106/accelerometer-onsensorchanged-not-called-when-screen-is-off

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!