Android screen lock/ unlock programmatically
and
How to lock/unlock phone programmatically : Android
and many questions i have searched for answer b
You can use the below code to open password/pin/pattern screen and validate user device credentials:
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
KeyguardManager km = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);
if (km.isKeyguardSecure()) {
Intent authIntent = km.createConfirmDeviceCredentialIntent(getString(R.string.dialog_title_auth), getString(R.string.dialog_msg_auth));
startActivityForResult(authIntent, INTENT_AUTHENTICATE);
}
}
and also implement onActivityResult's method to get the results in your case is successful or not.
// call back when password is correct
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == INTENT_AUTHENTICATE) {
if (resultCode == RESULT_OK) {
//do something you want when pass the security
}
}
}
You can check ref URL from here