當前位置: 首頁>>代碼示例>>Java>>正文


Java KeyguardManager.KeyguardLock方法代碼示例

本文整理匯總了Java中android.app.KeyguardManager.KeyguardLock方法的典型用法代碼示例。如果您正苦於以下問題:Java KeyguardManager.KeyguardLock方法的具體用法?Java KeyguardManager.KeyguardLock怎麽用?Java KeyguardManager.KeyguardLock使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.app.KeyguardManager的用法示例。


在下文中一共展示了KeyguardManager.KeyguardLock方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: wakeAndUnlock

import android.app.KeyguardManager; //導入方法依賴的package包/類
private void wakeAndUnlock(boolean b) {
    if (b) {
        //獲取電源管理器對象
        powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
        //獲取PowerManager.WakeLock對象,後麵的參數|表示同時傳入兩個值,最後的是調試用的Tag
        wakeLock = powerManager.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.SCREEN_BRIGHT_WAKE_LOCK, TAG);

        // 屏幕解鎖
        KeyguardManager keyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
        KeyguardManager.KeyguardLock keyguardLock = keyguardManager.newKeyguardLock("unLock");

        keyguardLock.reenableKeyguard();
        keyguardLock.disableKeyguard(); // 解鎖

        //點亮屏幕
        wakeLock.acquire();
    } else {
        //釋放wakeLock,關燈
        wakeLock.release();
    }
}
 
開發者ID:qoli,項目名稱:MiHomePlus,代碼行數:22,代碼來源:MyAccessibility.java

示例2: wakeAndUnlock

import android.app.KeyguardManager; //導入方法依賴的package包/類
public static void wakeAndUnlock() {
    //獲取電源管理器對象
    PowerManager pm = getPowerManager();

    //獲取PowerManager.WakeLock對象,後麵的參數|表示同時傳入兩個值,最後的是調試用的Tag
    PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "bright");

    //點亮屏幕
    wl.acquire(1000);

    //得到鍵盤鎖管理器對象
    KeyguardManager km = getKeyguardManager();
    KeyguardManager.KeyguardLock kl = km.newKeyguardLock("unLock");

    //解鎖
    kl.disableKeyguard();
}
 
開發者ID:A-Miracle,項目名稱:QiangHongBao,代碼行數:18,代碼來源:NotifyUtils.java

示例3: onCreate

import android.app.KeyguardManager; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    // add flag to current window
    Window window = this.getWindow();
    window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
    window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
    window.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);

    // init KeyguardManager

    KeyguardManager keyguardManager = (KeyguardManager)getSystemService(KEYGUARD_SERVICE);

    if (keyguardManager.inKeyguardRestrictedInputMode()) {
        KeyguardManager.KeyguardLock keyguardLock = keyguardManager.newKeyguardLock(getLocalClassName());
        keyguardLock.disableKeyguard();
    }

    // wake up screen light
    PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
    PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.SCREEN_DIM_WAKE_LOCK, "");
    wakeLock.acquire();

    // finish current activity
    finish();
}
 
開發者ID:macacajs,項目名稱:unlock-apk,代碼行數:29,代碼來源:MainActivity.java

示例4: wakeUpAndUnlock

import android.app.KeyguardManager; //導入方法依賴的package包/類
private void wakeUpAndUnlock(Context context)
{
	KeyguardManager km = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
	KeyguardManager.KeyguardLock kl = km.newKeyguardLock("unLock");
	// 解鎖
	kl.disableKeyguard();
	// 獲取電源管理器對象
	PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
	// 獲取PowerManager.WakeLock對象,後麵的參數|表示同時傳入兩個值,最後的是LogCat裏用的Tag
	PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.SCREEN_DIM_WAKE_LOCK, "bright");
	// 點亮屏幕
	wl.acquire();
	// 釋放
	wl.release();
}
 
開發者ID:stytooldex,項目名稱:stynico,代碼行數:16,代碼來源:MD5_jni.java

示例5: wake

import android.app.KeyguardManager; //導入方法依賴的package包/類
public static void wake(final Activity activity, final boolean disable_keyguard, final long lock_delayed) {
	try {
		// スリープ狀態から起床(android.permission.WAKE_LOCKが必要)
		final PowerManager.WakeLock wakelock = ((PowerManager)activity.getSystemService(Context.POWER_SERVICE))
			.newWakeLock(PowerManager.FULL_WAKE_LOCK
						| PowerManager.ACQUIRE_CAUSES_WAKEUP
						| PowerManager.ON_AFTER_RELEASE, "disableLock");
		if (lock_delayed > 0) {
			wakelock.acquire(lock_delayed);
		} else {
			wakelock.acquire();
		}
		// キーガードを解除(android.permission.DISABLE_KEYGUARDが必要)
		try {
			final KeyguardManager keyguard = (KeyguardManager)activity.getSystemService(Context.KEYGUARD_SERVICE);
			final KeyguardManager.KeyguardLock keylock = keyguard.newKeyguardLock(TAG);
			keylock.disableKeyguard();
		} finally {
			wakelock.release();
		}
		// 畫麵がOFFにならないようにする
		activity.getWindow().addFlags(
			WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
	} catch (final Exception e) {
		Log.w(TAG, e);
	}
}
 
開發者ID:saki4510t,項目名稱:libcommon,代碼行數:28,代碼來源:PowerHelper.java

示例6: onCreate

import android.app.KeyguardManager; //導入方法依賴的package包/類
@Override
public void onCreate() {
    mIsPhonePickUpWhileLocked.set(false);

    IntentFilter filter = new IntentFilter();
    filter.addAction(Intent.ACTION_SCREEN_ON);
    filter.addAction(Intent.ACTION_SCREEN_OFF);
    filter.addAction(Intent.ACTION_POWER_CONNECTED);
    filter.addAction(Intent.ACTION_POWER_DISCONNECTED);
    filter.addAction(Intent.ACTION_SHUTDOWN);
    filter.addAction("android.intent.action.PHONE_STATE");
    filter.addAction(LockHelper.INIT_VIEW_FILTER);
    filter.addAction(LockHelper.SHOW_SCREEN_LOCKER);
    filter.addAction(LockHelper.START_SUPERVISE);
    filter.addAction(CoreIntent.ACTION_SCREEN_LOCKER_UNLOCK);

    mReceiver = new LockBroadcastReceiver();

    mReceiver.assignPhoneStateChangeCallback(this);

    registerReceiver(mReceiver, filter);
    sendBroadcast(new Intent(LockHelper.INIT_VIEW_FILTER));

    KeyguardManager keyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
    KeyguardManager.KeyguardLock keyguardLock = keyguardManager.newKeyguardLock("KeyguardLock");
    keyguardLock.disableKeyguard();

    super.onCreate();
}
 
開發者ID:KyleCe,項目名稱:ScreenLocker2,代碼行數:30,代碼來源:LockScreenService.java

示例7: disableKeyguard

import android.app.KeyguardManager; //導入方法依賴的package包/類
@Deprecated
public static final void disableKeyguard(Context context) {
    Assert.assertNotNull(context);

    final KeyguardManager keyguardManager = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
    final KeyguardManager.KeyguardLock keyguardLock = keyguardManager.newKeyguardLock("KeyguardLock");
    keyguardLock.disableKeyguard();
}
 
開發者ID:KyleCe,項目名稱:ScreenLocker2,代碼行數:9,代碼來源:LockAffairs.java

示例8: unLock

import android.app.KeyguardManager; //導入方法依賴的package包/類
/**
 * 解鎖屏幕 需要的權限
 * <uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
 * @param context
 */
public static void unLock(Context context){
    //屏幕解鎖
    KeyguardManager keyguardManager = (KeyguardManager)context.getSystemService(Context.KEYGUARD_SERVICE);
    KeyguardManager.KeyguardLock keyguardLock = keyguardManager.newKeyguardLock("");
    keyguardLock.disableKeyguard();
}
 
開發者ID:baby2431,項目名稱:LemonUtils,代碼行數:12,代碼來源:ScreenUtils.java

示例9: lock

import android.app.KeyguardManager; //導入方法依賴的package包/類
/**
 * 鎖定屏幕
 * 需要的權限
 * <uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
 * @param context
 */
public static void lock(Context context){
    //屏幕解鎖
    KeyguardManager keyguardManager = (KeyguardManager)context.getSystemService(Context.KEYGUARD_SERVICE);
    KeyguardManager.KeyguardLock keyguardLock = keyguardManager.newKeyguardLock("");
    keyguardLock.reenableKeyguard();
}
 
開發者ID:baby2431,項目名稱:LemonUtils,代碼行數:13,代碼來源:ScreenUtils.java

示例10: wakePhoneAndUnlock

import android.app.KeyguardManager; //導入方法依賴的package包/類
private void wakePhoneAndUnlock() {
        PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE);
        PowerManager.WakeLock mWakelock = pm.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.FULL_WAKE_LOCK, "WakeLock");
        mWakelock.acquire();//喚醒屏幕
//......
        KeyguardManager mManager = (KeyguardManager)context.getSystemService(Context.KEYGUARD_SERVICE);
        KeyguardManager.KeyguardLock mKeyguardLock = mManager.newKeyguardLock("Lock");
//讓鍵盤鎖失效
        mKeyguardLock.disableKeyguard();
        mWakelock.release();//釋放
    }
 
開發者ID:JoeSteven,項目名稱:Moring-Alarm,代碼行數:12,代碼來源:AlarmReciver.java

示例11: unlockScreen

import android.app.KeyguardManager; //導入方法依賴的package包/類
@SuppressWarnings("deprecated")
private void unlockScreen() {
    KeyguardManager keyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
    final KeyguardManager.KeyguardLock keyguardLock = keyguardManager.newKeyguardLock("MyKeyguardLock");
    keyguardLock.disableKeyguard();

    PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
    PowerManager.WakeLock wakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK
            | PowerManager.ACQUIRE_CAUSES_WAKEUP
            | PowerManager.ON_AFTER_RELEASE, "MyWakeLock");

    wakeLock.acquire();
}
 
開發者ID:ChanJLee,項目名稱:OkRedEnvelopes,代碼行數:14,代碼來源:MonitorService.java

示例12: onCreate

import android.app.KeyguardManager; //導入方法依賴的package包/類
@Override protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
  setContentView(R.layout.activity_main);

  KeyguardManager keyguardManager = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);
  KeyguardManager.KeyguardLock keyguardLock = keyguardManager.newKeyguardLock("");
  keyguardLock.disableKeyguard();
}
 
開發者ID:beilly,項目名稱:BroadcastTest,代碼行數:10,代碼來源:SecondActivity.java

示例13: getKeyguardLock

import android.app.KeyguardManager; //導入方法依賴的package包/類
public KeyguardManager.KeyguardLock getKeyguardLock() {
    return keyguardLock;
}
 
開發者ID:jeasinlee,項目名稱:AndroidBasicLibs,代碼行數:4,代碼來源:KeyguardLock.java

示例14: setKeyguardLock

import android.app.KeyguardManager; //導入方法依賴的package包/類
public void setKeyguardLock(KeyguardManager.KeyguardLock keyguardLock) {
    this.keyguardLock = keyguardLock;
}
 
開發者ID:jeasinlee,項目名稱:AndroidBasicLibs,代碼行數:4,代碼來源:KeyguardLock.java

示例15: onCreate

import android.app.KeyguardManager; //導入方法依賴的package包/類
@Override
public void onCreate() {
    KeyguardManager.KeyguardLock k1;


    KeyguardManager km =(KeyguardManager)getSystemService(KEYGUARD_SERVICE);
    k1= km.newKeyguardLock("IN");
    k1.disableKeyguard();

    IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON);
    filter.addAction(Intent.ACTION_SCREEN_OFF);

    mReceiver = new LockscreenReceiver();
    registerReceiver(mReceiver, filter);


    super.onCreate();


}
 
開發者ID:puntubabu,項目名稱:LockaFlocka,代碼行數:21,代碼來源:LockScreenService.java


注:本文中的android.app.KeyguardManager.KeyguardLock方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。