我在我的android應用程序中使用了指紋登錄。如何從onAuthenticationSucceeded方法調用另一個類的方法?
如果認證成功,它會調用onAuthenticationSucceeded方法。
成功驗證指紋後,我想驗證onAuthenticationSucceeded內的用戶名。
但我無法在onAuthenticationSucceeded方法內調用另一個類的方法(用於驗證用戶名)。
該應用似乎總是被停止。
我怎麼能達到它? 請幫幫我。 謝謝
這是我FingerprintHandler.java
public void onAuthenticationSucceeded(FingerprintManager.AuthenticationResult result{
login log=new login(); log.unameCheck(); }這是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(); } }
-
的方法
這是我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; }android系統監視器顯示的例外是
Java.lang.NullPointerExceptio:Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference
This is the code I referred for my project from android authority
我曾經嘗試過,但verfyUsername()方法不能被調用。 – Michel
登錄日誌=新登錄(); – Michel
log.unameCheck(); – Michel