gpt4 book ai didi

android - 匿名登录和用户名 : Firebase + AuthUI

转载 作者:行者123 更新时间:2023-11-30 00:59:54 25 4
gpt4 key购买 nike

我是 Firebase 和 Firebase Auth UI 的新手,有两个问题:

  1. 我正在使用 Firebase Auth UI 进行简单的登录 Activity 。如何在屏幕上添加匿名登录选项?该选项在 Firebase 控制台中激活。
  2. 如何为用户添加用户名/昵称?注册完成后添加是可以的,但是我必须调用哪个方法?

这是我的代码:

  @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();
}
}
}

最佳答案

您可以从 link 中找到所有可能的 Firebase 登录实现.

Q1. I am using Firebase Auth UI for a simple login activity. How can I add a anonymous login option to the screen? The option is activated in the Firebase console.

../AnonymousAuthActivity.java

Q2. How can I add a username / nickname to the user? It is okay to add it after the registration completed, but which method do I have to call?

.../EmailPasswordActivity.java

关于android - 匿名登录和用户名 : Firebase + AuthUI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39580080/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com