开发者

Android disable screen saver

I'd like to disable screen saver while my appliction is running. How it can be done? Where is the best place to disable / enable the screen saver? in the first activity? in the applicatio开发者_如何学运维n.java?


The wake lock permission must be specified in the manifest.

<uses-permission android:name="android.permission.WAKE_LOCK" />

Then in the activity use the following to keep the screen on while the activity is running.

getWindow().addFlags(LayoutParams.FLAG_KEEP_SCREEN_ON);

Remember that unnecessarily keeping the screen on unnecessarily drains power from the user's device.


You must also add:

import android.view.WindowManager.LayoutParams;

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜