コード例 #1
0
  @Override
  public void onPause() {
    if (mKeyguardLock != null) {
      mKeyguardLock.reenableKeyguard();
    }

    mWakeLock.releaseWakeLock();
    super.onPause();
  }
コード例 #2
0
  @Override
  public void onResume() {
    super.onResume();
    KeyguardManager mKeyGuardManager = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);
    mKeyguardLock = mKeyGuardManager.newKeyguardLock("screenunlock");
    mKeyguardLock.disableKeyguard();

    mWakeLock = new WakeLockManager(getBaseContext());
    mWakeLock.setWakeLock(true, true);
  }