disable Keyguard - Android android.app

Android examples for android.app:KeyguardManager

Description

disable Keyguard

Demo Code

import android.app.KeyguardManager;
import android.app.KeyguardManager.KeyguardLock;
import android.content.Context;
import android.util.Log;

public class Main {

  private static final String TAG = "SystemUtils";

  private static KeyguardLock mKeyguardLock = null;

  /**/*from www  . j a  v a  2  s.  c o  m*/
   * unlock the screen
   * 
   * @param context
   * @since V1.0
   */
  public static void disableKeyguard(Context context) {
    if (null == mKeyguardLock) {
      KeyguardManager keyguardManager = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
      mKeyguardLock = keyguardManager.newKeyguardLock("unLock");
    }

    try {
      mKeyguardLock.disableKeyguard();
    } catch (Exception e) {
      Log.e(TAG, e.getMessage());
    }
  }

}

Related Tutorials