锁定和解锁屏幕,同时单击android中的按钮

时间:2011-06-06 10:44:20

标签: android

  

可能重复:
  Lock the android device programmatically

我尝试通过点击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;

0 个答案:

没有答案