Popup verify native password android -


i want user type password , press ok button, , check whether device's password. if app close , if not pop try again.

  new materialdialog.builder(finished.this)                     .title("to exit enter phone password")                     .inputtype(inputtype.type_class_text | inputtype.type_text_variation_password)                     .positivetext(r.string.ok)                     .negativetext(r.string.cancle)                     .input(r.string.input_hint, integer.parseint(""), new materialdialog.inputcallback() {                         @override                         public void oninput(materialdialog dialog, charsequence input) {                             //                         }                     })                     .callback(new materialdialog.buttoncallback() {                         @override                         public void onpositive(materialdialog dialog) {                             onbackpressed();                         }                     })                     .show(); 

for obvious security reasons, ordinary apps not permitted check values against device password.

in api level 21, there new method keyguardmanager.createconfirmdevicecredentialintent returns intent you. can call startactivityforresult intent confirm device password.

added in api level 21.

get intent prompt user confirm credentials (pin, pattern or password) current user of device. caller expected launch activity using startactivityforresult(intent, int) , check result_ok if user completes challenge.

returns intent launching activity or null if no password required.

class myactivity extends activity {    public static final int request_pwd_prompt = 1;    void promptfordevicepassword() {      // instance of keyguardmanager      keyguardmanager km = (keyguardmanager) this.getsystemservice(context.keyguard_service);      // intent prompt user      intent intent = km.createconfirmdevicecredentialintent("my app name", "enter password exit app.");       // launch intent      startactivityforresult(intent, request_pwd_prompt);   }    @override   protected void onactivityresult (int requestcode, int resultcode, intent data){       // see if being called our password request..?       if (requestcode == request_pwd_prompt) {           // ..it is. did user password right?           if (resultcode == result_ok) {             // got right           } else {             // got wrong/cancelled           }       }   }   } 

Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -