Max Reid-Williams
Max Reid-Williams

Reputation: 7

How do I move from one activity to another through the use of a java file?

I created this java file in android studio in order to validate the results of Nexus Imprint inputs, I want the user to be shown a new activity if the result of the input is correct (matched fingerprint). I currently have the following code:

public class FingerprintHandler extends
    FingerprintManager.AuthenticationCallback {

private CancellationSignal cancellationSignal;
private Context appContext;

public FingerprintHandler(Context context) {
    appContext = context;
}

public void startAuth(FingerprintManager manager,
                      FingerprintManager.CryptoObject cryptoObject) {

    cancellationSignal = new CancellationSignal();

    if (ActivityCompat.checkSelfPermission(appContext,
            Manifest.permission.USE_FINGERPRINT) !=
            PackageManager.PERMISSION_GRANTED) {
        return;
    }
    manager.authenticate(cryptoObject, cancellationSignal, 0, this, null);
}

@Override
public void onAuthenticationError(int errMsgId,
                                  CharSequence errString) {
    Toast.makeText(appContext,
            "Authentication error\n" + errString,
            Toast.LENGTH_SHORT).show();
}

@Override
public void onAuthenticationHelp(int helpMsgId,
                                 CharSequence helpString) {
    Toast.makeText(appContext,
            "Authentication help\n" + helpString,
            Toast.LENGTH_SHORT).show();
}

@Override
public void onAuthenticationFailed() {
    Toast.makeText(appContext,
            "Authentication failed.",
            Toast.LENGTH_SHORT).show();
}

@Override
public void onAuthenticationSucceeded(
        FingerprintManager.AuthenticationResult result) {
    appContext.startActivity(new Intent(this, MainActivity.class));
    Toast.makeText(appContext,
            "Authentication succeeded.",
            Toast.LENGTH_LONG).show();

}

I currently have a problem with the following code:

appContext.startActivity(new Intent(this, MainActivity.class));

I would like the user to be transfered from the FingerprintHandler activity to the Main_Activity, could somone please help me fix the problem, or show me another way round it? Cheers, Max

Upvotes: 0

Views: 240

Answers (1)

user5125586
user5125586

Reputation:

Firstly, what is the logcat saying?

Just incase, have you also tried using appContext.startActivity(new Intent(appContext, MainActivity.class));?

Upvotes: 1

Related Questions