保持螢幕常亮方式一:
public class textactivity extends activity
sdk文件關於flag_keep_screen_on的解釋如下:
flag_keep_screen_on
added in api level 1
int flag_keep_screen_on
window flag: as long as this window is visible to the user, keep the device's screen turned on and bright.
constant value: 128 (0x00000080)
即當window對使用者可見時,保持螢幕常亮。
當需要對window常亮狀態進行靈活控制的時候,呼叫api
getwindow().clearflags(windowmanager.layoutparams.flag_keep_screen_on);
方式二:xml中配置android:keepscreenon="true"(等同於flag_keep_screen_on),缺點不能靈活控制
...
Android保持螢幕常亮
方法一 新增許可權 powermanager pm powermanager getsystemservice context.power service powermanager.wakelock mwakelock pm.newwakelock powermanager.screen dim w...
andorid保持螢幕常亮
步驟一 獲取電源管理器,獲取喚醒鎖 mpowermanager powermanager getsystemservice power service mwakelock mpowermanager.newwakelock powermanager.screen bright wake lock,a...
Android 保持螢幕常亮
在activity的oncreate bundle 中新增以下 getwindow addflags windowmanager.layoutparams.flag keep screen on clearflags int 方法用來關閉 getwindow clearflags windowman...