开发者

Disabling screen sleep Programmatically in Android?

开发者 https://www.devze.com 2023-01-26 09:57 出处:网络
Can you please tell me how to prevent the Android Activity from sleep mode programmatically. Or can we declare someth开发者_开发技巧ing related to this in Android Manifest file.setKeepScreenOn(true)Yo

Can you please tell me how to prevent the Android Activity from sleep mode programmatically. Or can we declare someth开发者_开发技巧ing related to this in Android Manifest file.


setKeepScreenOn(true)


You can do

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

You can add this code in your onCreate() method of your activity. or you can put it in your xml file

android:keepScreenOn="true"
0

精彩评论

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