i did this to detect when the pincode is the right and when it's wrong :
public class AdminReceiver extends DeviceAdminReceiver {
@Override
public void onEnabled(Context ctxt, Intent intent) {
ComponentName cn=new ComponentName(ctxt, AdminReceiver.class);
DevicePolicyManager mgr=
(DevicePolicyManager)ctxt.getSystemService(Context.DEVICE_POLICY_SERVICE);
mgr.setPasswordQuality(cn,
DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC);
onPasswordChanged(ctxt, intent);
}
@Override
public void onPasswordChanged(Context ctxt, Intent intent) {
DevicePolicyManager mgr=
(DevicePolicyManager)ctxt.getSystemService(Context.DEVICE_POLICY_SERVICE);
int msgId;
if (mgr.isActivePasswordSufficient()) {
msgId=R.string.compliant;
}
else {
msgId=R.string.not_compliant;
}
Toast.makeText(ctxt, msgId, Toast.LENGTH_LONG).show();
}
@Override
public void onPasswordFailed(Context ctxt, Intent intent) {
Toast.makeText(ctxt, R.string.password_failed, Toast.LENGTH_LONG)
.show();
}
@Override
public void onPasswordSucceeded(Context ctxt, Intent intent) {
Toast.makeText(ctxt, R.string.password_success, Toast.LENGTH_LONG)
.show();
}
}
And i want the phone to take a picture into the OnPasswordFailed method into the camera roll how can i do that ? instead of the simple toast.