Here you can find the source of turnScreenOn(Activity context)
Parameter | Description |
---|---|
context | The current Activity Context from which this method is called |
public static void turnScreenOn(Activity context)
//package com.java2s; import android.app.Activity; import android.util.Log; import android.view.Window; import android.view.WindowManager; public class Main { /**/*from w ww. j a v a 2 s .co m*/ * Purpose - Force screen to turn on if the phone is asleep. * * @param context The current Activity Context from which this method is called */ public static void turnScreenOn(Activity context) { if (context == null) return; 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("Adroit", "Unable to turn on screen for activity " + context); } } }