2013-02-15 108 views
0

**有沒有什麼辦法可以讓我們在整個應用程序中始終保持屏幕亮度,但是一旦我們觸摸屏幕後它會一直醒來,請幫助它。 在此先感謝如何處理屏幕亮度

+0

谷歌它...你試過什麼? – Navdroid 2013-02-15 07:33:43

+0

http://stackoverflow.com/questions/3723634/how-do-i-prevent-an-android-device-from-going-to-sleep-programmatically – 2013-02-15 07:37:28

回答

0

試試這個代碼:

WindowManager.LayoutParams params = 
getWindow().getAttributes(); 
params.flags |= LayoutParams.FLAG_KEEP_SCREEN_ON; 
params.screenBrightness = YourValue; 
getWindow().setAttributes(params); 
0
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); 
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "My Tag"); 
wl.acquire(); 
    //..screen will stay on during this section.. 
wl.release(); 

不要忘了許可,並請google一下,下一次.... http://developer.android.com/reference/android/os/PowerManager.html