1

I used the below code to put a password screen lock...but when the activity is called my app crashes. Do I need to add any permissions in Android manifest? How do I go about this?

public class LockDevice extends Activity{

    public static DevicePolicyManager  devicePolicyManager;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);

        DevicePolicyManager devicePolicyManager =(DevicePolicyManager)getApplicationContext().getSystemService(Context.DEVICE_POLICY_SERVICE);
            ComponentName demoDeviceAdmin =new ComponentName(this, LockDevice.class);

            devicePolicyManager.setPasswordQuality(demoDeviceAdmin,DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED);
            devicePolicyManager.setPasswordMinimumLength(demoDeviceAdmin, 5);

            boolean result = devicePolicyManager.resetPassword("123456", DevicePolicyManager.RESET_PASSWORD_REQUIRE_ENTRY);

            Toast.makeText(this, "button_lock_password_device..."+result,  Toast.LENGTH_LONG).show();   
    }

}
userb
  • 25
  • 2
  • 8
  • Use this [library](https://github.com/wordpress-mobile/Android-PasscodeLock) or refer to this [link](http://stackoverflow.com/questions/18209791/can-i-make-pattern-password-screen-locker-android-app) – hrskrs Feb 01 '15 at 07:45

0 Answers0