Code example for PowerManager

Methods: isScreenOn, newWakeLock

0
	 * 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
				| PowerManager.ACQUIRE_CAUSES_WAKEUP
				| PowerManager.ON_AFTER_RELEASE, tag);
		wl.acquire();
		wl.release(); // ON_AFTER_RELEASE flag keeps screen on for some time
	} 
}