Android light screen or screen unlock and lock and other related permissions to implement code _android

Source: Internet
Author: User
1, Android screen illuminated steady/light
Copy Code code as follows:

Keep Screen illuminated steady
PowerManager pm = (powermanager) getsystemservice (Context.power_service);
Mwakelock = Pm.newwakelock (Powermanager.full_wake_lock | Powermanager.acquire_causes_wakeup, Lock_tag);
Mwakelock.acquire ();

Copy Code code as follows:

Release screen illuminated steady lock
if (null!= mwakelock) {
Mwakelock.release ();
}

2, Android screen unlock and lock
Copy Code code as follows:

Screen unlock
Keyguardmanager Keyguardmanager = (keyguardmanager) getsystemservice (Keyguard_service);
Keyguardlock Keyguardlock = Keyguardmanager.newkeyguardlock (Lock_tag);
Keyguardlock.disablekeyguard ();
Screen lock
Keyguardlock.reenablekeyguard ();

3. Related Rights
Copy Code code as follows:

<uses-permission android:name= "Android.permission.DISABLE_KEYGUARD"/>
<uses-permission android:name= "Android.permission.WAKE_LOCK"/>
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.