Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 822
Glitch Avatar asked May 21 '11 08:05

Glitch


1 Answers

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.

like image 129
Haris Hasan Avatar answered Sep 24 '22 19:09

Haris Hasan