android 保持屏幕长亮及解锁的方法

在onCreate()中加入以下代码可以实现Screen keep on && unlock

getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED  
                | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD  
                | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON  
                | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
 getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);

 

 

你可能感兴趣的:(android,on,screen,unlock)