|
发表于 2011-10-22 17:27:22
|
显示全部楼层
Re:Q
方法 1: use PowerManager and WakeLockAndroidManifest.xml权限:
<uses-permission android:name="android.permission.WAKE_LOCK" />
程序中的代码: PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock mWakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "My Tag");
// in onResume() call
mWakeLock.acquire();
...
// in onPause() call
mWakeLock.release();
[/code]方法 2: use the window flag FLAG_KEEP_SCREEN_ON把下面的代码加入到程序onCreate方法中: @Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
// Set keep screen on
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
[/code] |
|