I am trying to change the brightness using the volume buttons. I was able to get and set the brightness (as in I'm not getting an error...) but its not working. If I Log the brightness value after changing it the value is unchanged...
This is my code:
My phone (Note 2) returns brightness values from 20 to 255. Since the SetScreenBrightness function accepts a float from 0 to 1 I'm changing it to float by dividing by 255 (the max value). Im also limiting the values to a minimum of 20 and maximum of 255... Everything seems to be working since it is going into each of the if constructs... but still the brightness does not change!
What am I doing wrong?
This is my code:
B4X:
Sub Activity_KeyPress (KeyCode As Int) As Boolean 'Return True to consume the event
Log("Brightness: " & p.GetSettings("screen_brightness"))
If KeyCode = KeyCodes.KEYCODE_VOLUME_UP Then
p.SetScreenBrightness(Min((p.GetSettings("screen_brightness")+5),255)/255)
Return True
Else If KeyCode = KeyCodes.KEYCODE_VOLUME_DOWN Then
p.SetScreenBrightness(Max((p.GetSettings("screen_brightness")-5),20)/255)
Return True
End If
End Sub
My phone (Note 2) returns brightness values from 20 to 255. Since the SetScreenBrightness function accepts a float from 0 to 1 I'm changing it to float by dividing by 255 (the max value). Im also limiting the values to a minimum of 20 and maximum of 255... Everything seems to be working since it is going into each of the if constructs... but still the brightness does not change!
What am I doing wrong?