How to detect if PIN/password/pattern is required to unlock phone?

Shatazone picture Shatazone · Oct 24, 2011 · Viewed 18.1k times · Source

How can I detect if the phone is locked by a password, pin or pattern?

thank you!

Answer

Dori picture Dori · Jan 6, 2015

Two methods

  1. Check programatically - API 16+

https://gist.github.com/doridori/54c32c66ef4f4e34300f

Note that you dont need to check for face unlock as that requires that a pin/pass fallback is set.

  1. Device Admin Policies

Can also look into the Device Admin Policies which allow restrictions on how the app is setup regarding security including pin/pass set restrictions

As an aside, these are the lock types you want to check for if using an encrypted Keystore. Check here for more info.