In my application, I want to check whether the user has set the password in their android device or not? I tried using device admin apis m not able to get those information. Is there any other way?
Asked
Active
Viewed 2,845 times
2
-
Check out this answer: http://stackoverflow.com/questions/5322291/how-to-detect-if-pin-code-is-required-to-unlock-sim – David Jashi Jun 04 '13 at 05:56
-
Thanks for your post, m asking for device password. – kumar_android Jun 04 '13 at 05:58
-
Now I got it. Then you'll have to be more specific: on my phone there are password lock, swipe pattern lock, face lock, God knows what else. Which one do you need? – David Jashi Jun 04 '13 at 06:01
-
Awww sorry! I need password lock is set in device or not? – kumar_android Jun 04 '13 at 06:03
-
Anyway, take a look here: http://developer.android.com/guide/topics/admin/device-admin.html – David Jashi Jun 04 '13 at 06:03
-
I already tried that, we can only set password with complexity, not able to find it out – kumar_android Jun 04 '13 at 06:06
-
This may be made intentionally inaccessible... What do you need this for? Maybe there is some other way to achieve your goal? – David Jashi Jun 04 '13 at 06:07
-
I doing device info app, want to collect those details and send to the server. – kumar_android Jun 04 '13 at 06:21
1 Answers
1
Device administrator doesn't allow you to check whether device has lock screen password (or pattern ...) directly.
However you can do it indirectly.
- Retrieve password quality level from device admin (original value)
- Set password quality to device admin to minimum level (i.e. PASSWORD_QUALITY_SOMETHING)
- Ask device admin whether is password quality sufficient (if true = user has password)
- Restore original password quality level (value from step 1)
DevicePolicyManager allows you to set/get required password quality level and check whether is password sufficient.
Your device admin will need to use limit-pasword policy:
<device-admin xmlns:android="http://schemas.android.com/apk/res/android">
<uses-policies>
<limit-password />
</uses-policies>
</device-admin>
And you should definetely read this Device Administrator Guide.

stevo.mit
- 4,681
- 4
- 37
- 47