我想按HOME_BUTTON鍵設置屏幕。單擊主頁按鈕設置屏幕
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_HOME) {
System.out.println("home button");
finish();
WindowManager.LayoutParams params = getWindow().getAttributes();
params.flags |= LayoutParams.FLAG_KEEP_SCREEN_ON;
params.screenBrightness = 0;
getWindow().setAttributes(params);
return true;
}
return super.onKeyDown(keyCode, event);
}
任何一個可以幫助我 謝謝
那麼你嘗試過什麼追趕Home鍵旁邊? – WarrenFaith
http://stackoverflow.com/questions/9294917/android-java-turn-screen-off – keshav
@khouloudmejdoub您應該將該代碼添加到您的問題,而不是一個不可讀的評論... – WarrenFaith