我尝试通过点击android中的按钮来锁定和解锁屏幕。帮我完成代码。我使用以下代码锁定屏幕,但我在解锁时面临问题。
Window mywindow = getWindow();
WindowManager.LayoutParams lp = mywindow.getAttributes();
mywindow.addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
mywindow.setAttributes(lp);
s=false;
// Log.w(LOG_TAG, "Screen goes off!");
} else {
lock.setImageResource(R.drawable.unlockicon);
Window mywindow = getWindow();
WindowManager.LayoutParams lp = mywindow.getAttributes();
mywindow.clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
mywindow.setAttributes(lp);
s=true;