i would like to use following code to turn off Button back that i got from https://stackoverflow.com/a/4937448/1218762
final Window win = getWindow();
final WindowManager.LayoutParams winParams = win.getAttributes();
winParams.flags |= WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
//set screen brightness to the lowest possible
winParams.screenBrightness = 0.01f;
if (Build.VERSION.SDK_INT < 8) {
// hack for pre-froyo to set buttonBrightness off
try {
Field buttonBrightness = winParams.getClass().getField(
"buttonBrightness");
buttonBrightness.set(winParams, 0);
} catch (Exception e) {
e.printStackTrace();
}
} else {
winParams.buttonBrightness = 0;
}
win.setAttributes(winParams);
Reference : visit Night Mode where you you can turn off Button Lights in Service , i know Services don’t have Window but how is it possible ?
Thank You.
One of the simple way I would suggest you is to broadcast some kind of turning-off message from your
Serviceto yourActivityand perform the required actions inside onReceive method ofBroadcastReceiver.