1
我是相當新的火力地堡和火力地堡驗證UI和有兩個問題:匿名登錄和用戶名:火力地堡+ AuthUI
- 我使用火力地堡驗證UI進行了簡單的登錄活動。我如何在屏幕上添加匿名登錄選項?該選項在Firebase控制檯中激活。
- 如何爲用戶添加用戶名/暱稱?在註冊完成後添加它是可以的,但是我必須撥打哪種方法?
這裏是我的代碼:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
FirebaseAuth auth = FirebaseAuth.getInstance();
if (auth.getCurrentUser() != null) {
// User is already signed in
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
startActivity(intent);
} else {
// User isn't already signed in
startActivityForResult(
AuthUI.getInstance()
.createSignInIntentBuilder()
.setProviders(
AuthUI.EMAIL_PROVIDER,
AuthUI.GOOGLE_PROVIDER)
.setLogo(R.mipmap.ic_launcher)
.build(),
RC_SIGN_IN);
}
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RC_SIGN_IN) {
if (resultCode == RESULT_OK) {
// user is signed in!
startActivity(new Intent(this, MainActivity.class));
finish();
} else {
Toast.makeText(LoginActivity.this, "Error during login :(", Toast.LENGTH_SHORT).show();
}
}
}
好吧,TY的答案,但我也許誤解的東西..我不設計由我自己登錄的用戶界面,我現在用的是prebuilded UI AuthUI.getInstance ().createSignInIntentBuilder()..... – jdstaerk
阿哈對不起,我錯過了這一點。 AuthUI不支持匿名登錄。對於設置AuthUI.EMAIL_PROVIDER的用戶名,必須出現用戶名和密碼字段,但我仍然試用它 – uguboz
好了^^最後一個問題:如何設置用戶通過Facebook/Google登錄的用戶名?有沒有「Firebaseuser.getInstance()。setUsername(」MyUsername「)」的功能? ; D – jdstaerk