title: skip the screenlock
body: <pre><code>protected void onPause()
      {
          super.onPause();        
  
          // If the screen is off then the device has been locked
          PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
          boolean isScreenOn = powerManager.isScreenOn();
  
          //screen locked 
          if (!isScreenOn) {
  
              boolean pressed = onKeyDown(26, null);
  
              //power button pressed
              if(pressed){
                  //remove keyguard
                  getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);                 
                  getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
  
                  //start intent
                  Intent i = new Intent(this, VoiceRecognitionActivity.class);
                  startActivity(i);
              }
  
  
          }
      }    
  </code></pre>
  
  <p>the above code does is when power button is pressed, the keyguard will be dismissed and the activity onpaused will be resumed.</p>
  
  <p>However, the keyguard is not dimissed when i pressed the power button, and i have to unlock manually. </p>
  
  <p>When i pressed the power button, the window of my activity flashed for a second and the keyguard window is shown.</p>