android - How to call a method of another class from onAuthenticationSucceeded method? -
i have used fingerprint login in android app. if authentication success,it call onauthenticationsucceeded method. after success authentication of fingerprint want verify username within onauthenticationsucceeded. couldn't call method(for verifying username) of class within onauthenticationsucceeded method. app seems stopped.
how acheive it? please me. thank you
this in fingerprinthandler.java
public void onauthenticationsucceeded(fingerprintmanager.authenticationresult result{ login log=new login(); log.unamecheck(); }
this method in login.java
public void unamecheck(){ string uname=edit_username.gettext().tostring(); string storedpassword=mydb.getsingleentry(uname); if(storedpassword!=0){ toast.maketext(login.this,"login successfull",toast.length_long).show(); intent intent =new intent("michel.maan.login1"); startactivity(intent); } else{ toast.maketext(login.this,"login failed",toast.length_long).show(); } }
this databasehelper.java
public string getsingleentry(string username){ sqlitedatabase db=this.getwritabledatabase(); cursor cursor=db.query("user_table".null,"name=?",new string[]{username},null,null,null); if(cursor.getcount()<1){
cursor.close();
return"not exist"; } cursor.movetofirst(); string password=cursor.getstring(cursor.getcolumnindex("password")); cursor.close(); return password; }the exception showing in android monitor is
java.lang.nullpointerexceptio:attempt invoke virtual method 'android.content.res.resources android.content.context.getresources()' on null object reference
simplest way startactivity on onauthenticatinsucceed method , pass intent
intent intent=new intent(this,secondactivity.class); intent.putextra("authentication","done"); startactivity(intent);
and in oncreate of secondactiviy , check this
if(getintent.getextra("authentication").equals("done")) callverifyusername();
and if want can pass username fingerprintactivity in intent. if want previous screen if username not verified can call
finish();
Comments
Post a Comment