Android: Workaround for light sensor firing every time the Power button is pressed? -


i'm working on android app turns device's screen off when light sensor value below threshold value , turns screen on again when light sensor value rises above threshold value. threshold value decided user through one-time calibration. works great, screen turns on , off when it's supposed , i've dealt constant fluctuations in light sensor's values screen doesn't keep turning on , off randomly.

the issue i'm facing when power button pressed, light sensor's "onsensorchanged" event triggered reason. means if user presses power button turn screen off, it's automatically turn on if it's in right lighting.

the solution thought of keep flag variable won't allow code in service execute if power button pressed issue there android not allow me detect power button key press service.

is there possible (perhaps more logical) workaround issue?

i don't think helpful post code let me know if need me post it.

thanks.

instead of tracking flag power button press, why not keep flag when you turn off? way if turned off other reason, won't anything.

edit: idea...

what track last time action_screen_off intent fired. if time less threshold(0.05s?) when onsensorchanged called, can disregard(or @ least not turn on).


Comments

Popular posts from this blog

php - get table cell data from and place a copy in another table -

javascript - Mootools wait with Fx.Morph start -

php - Navigate throught databse rows -