我有一个允许用户注册的注册活动,并且在该活动中我有片段。第一个片段是供用户输入他们的信息,然后在传递多个要求后,应用程序会像这样创建用户
firebaseAuth.createUserWithEmailAndPassword(Email, Password).addOnCompleteListener(new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (!task.isSuccessful()) {
Toast.makeText(getActivity(), "Registration Failed",Toast.LENGTH_SHORT).show();
return;
}
//else Authentication Successful
ConfirmEmail nextFrag = new ConfirmEmail();
getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.relativeLayoutEmailPassword, nextFrag).addToBackStack(null).commit();
}
});
我的问题是,当我尝试切换到下一个片段(用于电子邮件验证)时,它只会启动我的MainActivity。
这是我片段的活动
public class SignUpActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sign_up);
Fragment fragment = new EmailPassword();
getSupportFragmentManager().beginTransaction().replace(R.id.relativeLayoutSignUp, fragment).commit();
}
}