3

In android device, we can have three types of lock as Pattern, PIN and password.

In my application, I want to change/reset the PIN pro-grammatically.

I am accepting 4-digits from user which will be set as a new PIN for that device.

Is it possible to reset this PIN or is it against the android security policy?

Thank You.

Naresh J
  • 2,087
  • 5
  • 26
  • 39

1 Answers1

2

You can do it by using Device Admin API. Where android gives you facility to make your own logic for Password (even more..). Read about how to implement password policy.

Note: You can get the sample code at <sdk>/samples/android-<version>/. The <version> number corresponds to the platform's API level.

Pankaj Kumar
  • 81,967
  • 29
  • 167
  • 186
  • hi can you tell us now is there any way to change the password as now the deviceamin api changed for android nougat. – Piyush Sep 23 '16 at 09:32
  • @piyush There no changes into password related APIs. They should work in Nougat also. – Pankaj Kumar Sep 23 '16 at 11:01
  • 1
    it is changed for android 7 please have a look.https://developer.android.com/reference/android/app/admin/DevicePolicyManager.html#resetPassword(java.lang.String, int) – Piyush Sep 24 '16 at 21:44
  • @piyush Yes you are correct. Thank you for correction. So as per doc, this API will only work if no password has been set to device. But this will work as expected in case of DEVICE OWNER or PROFILE OWNER. I will look into more and update answer in detail. – Pankaj Kumar Sep 26 '16 at 05:26