Skip to content

Instantly share code, notes, and snippets.

@oa414
Created March 11, 2013 12:06
Show Gist options
  • Select an option

  • Save oa414/5133796 to your computer and use it in GitHub Desktop.

Select an option

Save oa414/5133796 to your computer and use it in GitHub Desktop.
保持Android设备屏幕常亮
package com.example.AdmobTest;
import android.content.Context;
import android.os.PowerManager;
/**
* Created with IntelliJ IDEA.
* User: linxiangyu
* Date: 13-3-11
* Time: 下午7:56
* To change this template use File | Settings | File Templates.
*/
public class WakeUpUtils {
public static void setDeviceWakeUp(Context context){
/**
* require <uses-permission android:name="android.permission.WAKE_LOCK" />
*/
PowerManager manager = ((PowerManager)context.getSystemService(context.POWER_SERVICE));
PowerManager.WakeLock wakeLock = manager.newWakeLock(PowerManager.FULL_WAKE_LOCK, "TAG");
wakeLock.acquire();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment