本文整理汇总了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();
}
}
示例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();
}
示例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();
}
示例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();
}
示例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);
}
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();//释放
}
示例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();
}
示例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();
}
示例13: getKeyguardLock
import android.app.KeyguardManager; //导入方法依赖的package包/类
public KeyguardManager.KeyguardLock getKeyguardLock() {
return keyguardLock;
}
示例14: setKeyguardLock
import android.app.KeyguardManager; //导入方法依赖的package包/类
public void setKeyguardLock(KeyguardManager.KeyguardLock keyguardLock) {
this.keyguardLock = keyguardLock;
}
示例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();
}