posts - 71,  comments - 203,  trackbacks - 0

在Activity的onCreate()中:

PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock mWakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "My Tag");
// onResume() 中调用:

mWakeLock.acquire();
//  onPause() 中调用释放WakeLock对象
mWakeLock.release();

方法二: use the window flag FLAG_KEEP_SCREEN_ON

@Override
protected void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

posted on 2011-02-10 14:02  stay  阅读(483)  评论(0编辑  收藏