Android examples for User Interface:Screen Dormant
Force screen to turn on if the phone is asleep.
//package com.java2s; import android.app.Activity; import android.util.Log; import android.view.Window; import android.view.WindowManager; public class Main { /**/*from w w w. j ava 2 s .com*/ * Force screen to turn on if the phone is asleep. * * @param context The current Context or Activity that this method is called from */ public static void turnScreenOn(Activity context) { try { Window window = context.getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD); window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); window.addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); } catch (Exception ex) { Log.e("PercolateAndroidUtils", "Unable to turn on screen for activity " + context); } } }