內的窗口,我想用下面的代碼以關閉按鈕回來,我從https://stackoverflow.com/a/4937448/1218762得到交替使用Android服務
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);
參考:訪問 Night Mode在這裏你就可以在服務關閉按鈕亮起,我知道服務沒有窗口,但它怎麼可能?
謝謝。
你想打開服務中的按鈕背光嗎? –
是的參考,你可以看到從模擬應用程序播放 –