I've been working at this for quite awhile and can't figure it out, even though I thought it would be relatively easy. I am using Android's FingerprintManager to authenticate users via their fingerprint and it has worked very well. The issue is that I can't get the authentication results back from my helper class and it is very frustrating. I am pretty new to using helper classes and after googling it extensively, I still can't get the authentication results back into my activity. My best hope was to use intents with onActivityResult, however the helper class never sends out the intent (or atleast my main activity does not receive it).
For reference, my main class is an activity that uses a helper class (which extends .AuthenticationCallback) to check their fingerprints. The helper class contains the following methods:
public void startAuth(FingerprintManager manager, FingerprintManager.CryptoObject cryptoObject) {
cancellationSignal = new CancellationSignal();
if (ActivityCompat.checkSelfPermission(context, Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) {
return;
}
manager.authenticate(cryptoObject, cancellationSignal, 0, this, null);
}
@Override
public void onAuthenticationError(int errMsgId, CharSequence errString) {
}
@Override
public void onAuthenticationFailed() {
}
@Override
public void onAuthenticationHelp(int helpMsgId, CharSequence helpString) {
}
@Override
public void onAuthenticationSucceeded(FingerprintManager.AuthenticationResult result) {
Toast.makeText(context, "You have Been Successfully authenticated!", Toast.LENGTH_SHORT).show();
}
The code from the activity simply sends out the intent and has an onActivityResult method:
Intent btauthenticate = new Intent(getApplicationContext(), FingerPrintMainActivity.class);
startActivityForResult(authenticate, 1);
The fingerprints are authenticated successfully and I get my toast message, however I just don't know how to get the results back. I figure there must be an easy way to get the results back, but I just can't seem to figure it out and it's very frustrating. Any help is much appreciated.