标签:屏幕 android 亮度 windowmanager powermanager
【Android】如何调节屏幕亮度,关闭屏幕
工作中遇到的,记录一下。
方法1:
PowerManager manager = (PowerManager) getSystemService(Context.POWER_SERVICE); PowerManager.WakeLock wl = manager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Your Tag"); wl.acquire(); wl.release();
记得在AndroidManifest.xml中申请权限:
<uses-permission android:name="android.permission.WAKE_LOCK" />
方法2:
WindowManager.LayoutParams params = getWindow().getAttributes(); params.flags |= LayoutParams.FLAG_KEEP_SCREEN_ON; params.screenBrightness = 0; getWindow().setAttributes(params);
本文出自 “程序员联盟 frogoscar” 博客,请务必保留此出处http://4526621.blog.51cto.com/4516621/1710423
标签:屏幕 android 亮度 windowmanager powermanager
原文地址:http://4526621.blog.51cto.com/4516621/1710423