开发者

Getting lux value from light sensor without onSensorChanged() event?

Just wondering, is there a way to gain the value of the light sensor on an Android phone without waiting for an onSensorChanged() event to occur? To save battery I use registerListener() and unregisterListener() after getting a single lux value, however the next time I register the listener to get another value, if that value is the same as before, my application sits there waiting for an event which may take a while to occur (typically in low-light situations).

So, is there a way I can read the lux value without waiting for an onSensorChanged() event? Or should I just have a 100ms timeout and then use the开发者_开发问答 last value I recorded?

Thanks!


I also wanted to achieve the same for accelerometer or compass i.e. get the current value only without listening on to the change events and wait for any physical change to occur but after lot of search I have came to conclusion that it is not possible.

Only way to read value from these devices is to listen for events continuously.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜