Code example for KeyguardManager.KeyguardLock

Methods: disableKeyguard

0
	// just acquiring the WakeLock is not enough when a keyguard is on 
	public static void disableKeyguard(Context context){
		Log.v(tag, "Disabling keyduard - will be reenabled later when this process has died");
		KeyguardManager km = (KeyguardManager)context.getSystemService(Context.KEYGUARD_SERVICE);
		KeyguardLock klock = km.newKeyguardLock(tag);
		klock.disableKeyguard(); // will be re-enabled when this process has died
	} 
 
	/* 
	 * wake up the device when starting an app after an application request from the other side 
	 */ 
	public static void wakeUpIfNeeded(Context context, Handler poster) {
		PowerManager pm = (PowerManager) context
				.getSystemService(Context.POWER_SERVICE);
		if (pm.isScreenOn()) {
			Log.i(tag, "Screen is on, nothing needs to be done");
			return; 
		} else { 
			Log.i(tag, "Screen is off, will wake the device up now!");
		} 
		WakeLock wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK