Lock your phone using the Android application

Possible duplicate:
Lock Android device programmatically

I tried to block the phone using the application,

I tried the following code but not used, I also added user permissions.

KeyguardManager manager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE); KeyguardLock lock = manager.newKeyguardLock("hh"); lock.disableKeyguard(); lock.reenableKeyguard(); 

Please offer me a code to lock the phone.

0
source share
1 answer

Add this permission to the AndroidManifest.xml file

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

and

 KeyguardManager mgr = (KeyguardManager)getSystemService(Activity.KEYGUARD_SERVICE); KeyguardLock lock = mgr.newKeyguardLock(KEYGUARD_SERVICE); lock.reenableKeyguard(); 
0
source

All Articles