Android unlock screen lock with light on (incoming call effect)

Source: Internet
Author: User

PowerManager pm= (PowerManager) Getsystemservice (Context.power_service);

Get the Power Manager object

Powermanager.wakelock wl = Pm.newwakelock (Powermanager.acquire_causes_wakeup | Powermanager.screen_dim_wake_lock, "bright");

Gets the Powermanager.wakelock object, followed by the parameter | Indicates the simultaneous passing of two values, and the last is the tag wl.acquire () used in Logcat;

Light screen Keyguardmanager km= (Keyguardmanager) Getsystemservice (Context.keyguard_service);

Get the keyboard lock Manager Object Keyguardlock KL = Km.newkeyguardlock ("UnLock");

The parameter is the tag Kl.disablekeyguard () used in Logcat;

Unlock

/*

* Other code to write the program here

*

* */

Kl.reenablekeyguard ();

Re-enable auto lock

Wl.release ();

Release

You need to add permissions in Androidmanifest.xml:

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

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

Android unlock screen lock with light on (incoming call effect)

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.