转自:http://www.oschina.net/code/snippet_936286_23625
/**
* 保持屏幕唤醒状态(即背景灯不熄灭)*
* @param on
* 是否唤醒
*/
private static WakeLock wl;
public static void keepScreenOn(Context context, boolean on) {
if (on) {
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
wl = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, "==KeepScreenOn==");
wl.acquire();
} else {
if (wl != null) {
wl.release();
wl = null;
}
}
}