startActivityForResult(AuthUI.getInstance() 已弃用

时间:2021-03-29 16:56:17

标签: java

帮助 我的问题是它已经过时了 (startActivityForResult) 我该如何更新它?

从 Firebase 服务器生成验证时,它会要求用户进行 Captcha 验证

代码

private void phoneLogin() {

    startActivityForResult(AuthUI.getInstance()
            .createSignInIntentBuilder()
            .setLogo(R.drawable.logo_inicio)
            .setTheme(R.style.LoginTheme)
            .setAvailableProviders(providers).build(),
            APP_REQUEST_CODE);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == APP_REQUEST_CODE)
    {
        IdpResponse response = IdpResponse.fromResultIntent(data);
        if (resultCode == RESULT_OK)
        {
            FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
        }
        else
        {
            Toast.makeText(this, "Error de ingreso", Toast.LENGTH_SHORT).show();
        }
    }
}

0 个答案:

没有答案