我想實現在火力地堡用戶名註冊,因爲它只是給了我,就像是createUserWithEmailAndPassword()
方法,但你不能創建一個用戶名,我不知道該怎麼辦呢?如何在Firebase中註冊用戶名?
以下是我的註冊碼,但我也想輸入一個可以使用它的用戶名,當用戶發佈一些東西時,例如getEmail()
方法,也可以有一個getUsername()
。
auth.createUserWithEmailAndPassword(email, password).addOnCompleteListener(RegisterActivity.this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
progressBar.setVisibility(View.GONE);
if(!task.isSuccessful()){
Toast.makeText(RegisterActivity.this, "Something went wrong :(" , Toast.LENGTH_LONG).show();
}else{
startActivity(new Intent(RegisterActivity.this, UsernameARegistrarActivity.class));
finish();
}
}
});
}
我的模型類:
public class User implements Serializable{
private String user;
private String email;
private String Uid;
private String username;
public User() {
}
public User(String user) {
this.user = user;
}
public User(String user, String email, String uid, String username) {
this.user = user;
this.email = email;
Uid = uid;
this.username = username;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getUser() {
return user;
}
public void setUser(String user) {
this.user = user;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getUid() {
return Uid;
}
public void setUid(String uid) {
Uid = uid;
}
}
我這樣做,但沒有辦法恢復的值,對於特定的用戶,我不知道用什麼代碼我試過做到這一點http://stackoverflow.com/questions/43444174/how-can-i-get-some-value-from-my-firebase – TheQuestionerXxx