当前位置: 首页>>代码示例>>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;未经允许,请勿转载。