I have an app that sometimes may require a login in the middle of execution, and I'm tyring to figure out how to pass around control. There are quite a number of different things to do for authentication, so I have a utility class called Authenticator taking care of all that.
In short, I want it so all activites in the app will be able to call some method like Authenticator.login() to present a login screen, and have Authenticator take care of everything.
Here's what I've thought of so far for the login method:
public boolean login(Activity context)
{
Intent intent = new Intent(context, Login.class);
context.startActivityForResult(intent, LOGIN_ACTIVITY);
return false;
}
The problem I'm running into, though, is getting the result back from logging in. I want to know if they pressed the cancel button or had an incorrect password BEFORE I pass control back to the Activity that called login().
There is the method onActivityResult(), but that is in class Activity, whereas Authenticator is not an activity. Is there a way to start an activity for a result from inside a normal java class?