当前位置: 代码迷 >> Android >> android荧屏常亮
  详细解决方案

android荧屏常亮

热度:22   发布时间:2016-04-28 07:20:14.0
android屏幕常亮

在manifest.xml中配置权限:

<!--常亮权限  --><uses-permission android:name="android.permission.WAKE_LOCK"></uses-permission>

?

在activity的java文件中:

 @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);        //设置常亮        this.powerManager = (PowerManager)this.getSystemService(Context.POWER_SERVICE);        this.wakeLock = this.powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK, "My Lock");}//唤醒    @Override    protected void onResume(){    	super.onResume();    	this.wakeLock.acquire();    }    //暂停    @Override    protected void onPause(){    	super.onPause();    	this.wakeLock.release();    }

?

  相关解决方案