I am new in Android and I have few questions about when a new user account is created on phone authentication. I created a Register Activity and OTP Activity for user registration. After the user registration, I get the user's information and 5 Activity later I store the datas to Firebase. I can see the user's details and phone number in Firebase.
This is my OTP page:
private void signInWithPhoneAuthCredential(PhoneAuthCredential credential) {
FirebaseAuth firebaseAuth = FirebaseAuth.getInstance();
firebaseAuth.signInWithCredential(credential)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if(task.isSuccessful()){
Intent intent = new Intent(B_Verification_Activity.this, C_Name_Activity.class);
intent.putExtra("userPhone", comp_phoneNumber);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);
}
else{
return;
}
}
});
}
And this is my last activity that I store the datas in Firebase:
public void storeNewUserData() {
rootNode = FirebaseDatabase.getInstance();
String userId = firebaseAuth.getCurrentUser().getUid();
reference = rootNode.getInstance().getReference().child("Kullanıcılar").child(user_Gender.toString()).child(userId);
UserHelperClass addNewUser = new UserHelperClass(user_phoneNumber, user_FirstName, user_Gender, user_Birthdate, user_Hobbies);
reference.setValue(addNewUser);
}
But I don't know how user to login with phone number. In registration page, I just verified phone number, that's it. I don't know user is created or not in Register Activity. I want to create user in OTP activity. Is there any other code to I should write?
My english is not very good, thank you for helping.