本文整理匯總了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();
}