Android examples for User Interface:Screen Lock
Wake ups and release the screen lock.
//package com.java2s; import android.app.KeyguardManager; import android.content.Context; import android.os.PowerManager; public class Main { /**/*ww w .ja va 2s. com*/ * Wake ups and release the screen lock. * @param context */ public static void wakeLockWithScreenUnLock(Context context) { partialWakeUpLock(context); releaseScreenLock(context); } /** * Wake ups the phone. * @param context */ public static void partialWakeUpLock(Context context) { PowerManager pm = (PowerManager) context.getApplicationContext() .getSystemService(Context.POWER_SERVICE); PowerManager.WakeLock wakeLock = pm .newWakeLock( (PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP), "TAG"); wakeLock.acquire(); } /** * Release the devices screen lock. * @param context */ public static void releaseScreenLock(Context context) { KeyguardManager keyguardManager = (KeyguardManager) context .getApplicationContext().getSystemService( Context.KEYGUARD_SERVICE); KeyguardManager.KeyguardLock keyguardLock = keyguardManager .newKeyguardLock("TAG"); keyguardLock.disableKeyguard(); } }