首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Android >

Android有关问题-Android OnSensorChanged() not working when screen lock is on

2013-04-02 
Android问题----Android OnSensorChanged() not working when screen lock is onSome of the Android OS v

Android问题----Android OnSensorChanged() not working when screen lock is on

Some of the Android OS versions have a bug which stops the sensors such as the accelerometer recording when the screen lock is on.

The bug has been submitted but has not been fixed in all instances

http://code.google.com/p/android/issues/detail?id=3708

http://code.google.com/p/android/issues/detail?id=11028

Below is a list of Phones and OS versions the do and don’t have the bug + some are reported to be intermittent.

BugNo BugIntermittentMotorola Milestone – 2.1Google Nexus One – 2.2Google Nexus One – 2.2Nexus One – 2.1T-Mobile G1 – 1.6HTC Desire – 2.2Google ION – 1.6HTC EVO 4G – 2.2 Motorola Droid – 2.2 HTC Eris – 2.2 Droid Incredible – 2.2 HTC Legend 2.1HTC Wildfire 2.2

Update: There are a couple of workarounds that i have found

The first works for all phones but is a drain on the battery and involves keeping the screen on all the time. It changes the timeout of the screen to a higher number:

http://stackoverflow.com/questions/1114270/android-screen-timeout

The second seems to only work on some phones such as the Milestone and Droid which registers the sensor, then un-registers the sensor when the screen is off and re-registers the sensor. Long winded but if it works…

http://stackoverflow.com/questions/2143102/accelerometer-stops-delivering-samples-when-the-screen-is-off-on-droid-nexus-one

If you enjoyed this post, make sure you subscribe to my RSS feed!

热点排行