这是一个用户凭据检查的模拟,大部分代码是由 Android Studio 生成的。如果用户:通行证不存在,它会进行注册,但我不确定我应该将用户发送到主要活动的位置。请看一下checking mail & pass
部分。
/**
* Represents an asynchronous login/registration task used to authenticate
* the user.
*/
public class UserLoginTask extends AsyncTask<Void, Void, Boolean> {
@Override
protected Boolean doInBackground(Void... params) {
// TODO: attempt authentication against a network service.
try {
// Simulate network access.
Thread.sleep(1000);
} catch (InterruptedException e) {
return false;
}
// checking mail & pass
for (String credential : DUMMY_CREDENTIALS) {
String[] pieces = credential.split(":");
if (pieces[0].equals(mEmail)) {
// Account exists, return true if the password matches.
return pieces[1].equals(mPassword);
}
}
// TODO: register the new account here.
Intent i = new Intent(LoginActivity.this, RegisterActivity.class);
startActivity(i);
return true;
}
@Override
protected void onPostExecute(final Boolean success) {
mAuthTask = null;
showProgress(false);
if (success) {
finish();
} else {
mPasswordView.setError(getString(R.string.error_incorrect_password));
mPasswordView.requestFocus();
}
}
@Override
protected void onCancelled() {
mAuthTask = null;
showProgress(false);
}
}
在 user:pass 正确后,我在哪里开始主要活动?