Android防止屏幕休眠
1、在Manifest文件里声明权限
android.permission.WAKE_LOCK
2, 得到 WakeLock实例 ,
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
mWakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK,
"SoundRecorder");
3,防止休眠
mWakeLock.acquire();
4,释放
if (mWakeLock.isHeld())
mWakeLock.release();
(节选自录音机:com.android.soundrecorder.SoundRecorder.java)
2024年2月23日 19:33
Really impressed! Everything is very open and very clear clarification of issues. It contains truly facts. Your website is very valuable. Thanks for sharing.