Android lit screen with lock screen

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 argument | To pass in two values at the same time, and finally the tag used in Logcat.
Wl.acquire ();
Light the screen.

Keyguardmanager km= (Keyguardmanager) Getsystemservice (Context.keyguard_service);
Get the keyboard lock manager object
Keyguardlock KL = Km.newkeyguardlock ("UnLock");
parameter is the tag used in Logcat.
Kl.disablekeyguard ();
Unlock

/*
* Other code to write the program here
*
* */

Kl.reenablekeyguard ();
Re-enable auto lock
Wl.release ();
Release
};

I need a broadcast, alas.

Private Devicepolicymanager Policymanager;
Private ComponentName componentname;

@Override
protected void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);

StartService (New Intent (). Setaction ("Lzh00.workservice"));
Finish ();
Policymanager = (Devicepolicymanager) getsystemservice (Context.device_policy_service);
ComponentName = new ComponentName (this, myreceiver.class);

if (policymanager.isadminactive (componentname)) {//To determine if a permission is available (Device Manager activated)
Policymanager.locknow ();//Direct lock screen
Finish ();
} else {
Activemanager ();//Activate Device Manager Get Permissions
Finish ();
}

}

/**
* Get lock Screen permissions
*/
private void Activemanager () {
Activates the specified Device Manager using implicit intent to invoke the system method
Intent Intent = new Intent (devicepolicymanager.action_add_device_admin);
Intent.putextra (Devicepolicymanager.extra_device_admin, componentname);
Intent.putextra (Devicepolicymanager.extra_add_explanation, "one button lock screen");
StartActivity (Intent);
}

Android lit screen with lock screen

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.