I am trying to build an app in android which on launch checks whether the device is secure with any kind of pattern,or pin i found this method of keyguardManager isDeviceSecure() it says it return true if the device is secured with a PIN, pattern or password.
You can check this with the DevicePolicyManager:
DevicePolicyManager devicePolicyManager = (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE);
int passwordQuality = devicePolicyManager.getPasswordQuality(//componentName of device admin here);
if (passwordQuality == DevicePolicyManager.PASSWORD_QUALITY_SOMETHING) {
// Any password/pincode/swipe is set up.
}
if (devicePolicyManager.isActivePasswordSufficient()) {
// With this you can check if the device password is sufficient (for example if password quality changes).
}
You may need admin application rights to do this tough (unsure). Read more here : https://developer.android.com/reference/android/app/admin/DevicePolicyManager.html
EDIT:
You could also extend DeviceAdminReceiver in order to catch the Intent when a user changes his pin or password.
public class MyDeviceAdminReceiver extends DeviceAdminReceiver {
@Override
public void onPasswordChanged(Context context, Intent intent) {
// Display your dialog here if user set any type of password.
}
}