我无法解决来自Firebase身份验证的错误符号。

huangapple go评论84阅读模式
英文:

i can't resolve the errors symbol from firebase authentification

问题

我尝试使用电子邮件和密码进行Firebase连接,但在构建时出现了两个符号错误。

第一个错误来自于AnotherActivity.class,我不知道如何解决它:

public void updateUI(FirebaseUser account){
    if(account != null){
        Toast.makeText(this, "登录成功", Toast.LENGTH_LONG).show();
        startActivity(new Intent(this, AnotherActivity.class));
    } else {
        Toast.makeText(this, "未登录", Toast.LENGTH_LONG).show();
    }
}

第二个错误来自于EmailPasswordActivity.this

private void callsignin(String email, String password) {
    mAuth.signInWithEmailAndPassword(email, password)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    if (task.isSuccessful()) {
                        // 登录成功,更新UI显示已登录用户信息
                        Log.d("success", "signInWithEmail:success");
                        FirebaseUser user = mAuth.getCurrentUser();
                        updateUI(user);
                    } else {
                        // 如果登录失败,向用户显示一条消息
                        Log.w("failed", "signInWithEmail:failure", task.getException());
                        Toast.makeText(EmailPasswordActivity.this, "认证失败。",
                                Toast.LENGTH_SHORT).show();
                        updateUI(null);
                    }
                }
            });
}

我认为我需要在清单文件中做一些设置,但我不知道具体是什么。感谢您的关注,希望您能帮助我。

错误截图:
我无法解决来自Firebase身份验证的错误符号。

设置截图:
我无法解决来自Firebase身份验证的错误符号。

导入部分截图:
我无法解决来自Firebase身份验证的错误符号。

英文:

i try to do a firebase connection with email and password, but i ah two symbol errors when i try to build.

the first one come from the AnotherActivity.class i don't know how to resolve it

public void updateUI(FirebaseUser account){

    if(account != null){
        Toast.makeText(this,&quot;U Signed In successfully&quot;,Toast.LENGTH_LONG).show();
        startActivity(new Intent(this,AnotherActivity.class));

    }else {
        Toast.makeText(this,&quot;U Didnt signed in&quot;,Toast.LENGTH_LONG).show();
    }

}

and the second come from EmailPasswordActivity.this

private void callsignin(String email, String password) {
    mAuth.signInWithEmailAndPassword(email, password)
            .addOnCompleteListener(this, new OnCompleteListener&lt;AuthResult&gt;() {
                @Override
                public void onComplete(@NonNull Task&lt;AuthResult&gt; task) {
                    if (task.isSuccessful()) {
                        // Sign in success, update UI with the signed-in user&#39;s information
                        Log.d(&quot;success&quot;, &quot;signInWithEmail:success&quot;);
                        FirebaseUser user = mAuth.getCurrentUser();
                        updateUI(user);
                    } else {
                        // If sign in fails, display a message to the user.
                        Log.w(&quot;failed&quot;, &quot;signInWithEmail:failure&quot;, task.getException());
                        Toast.makeText(EmailPasswordActivity.this, &quot;Authentication failed.&quot;,
                                Toast.LENGTH_SHORT).show();
                        updateUI(null);
                    }

                }
            });
}

i think i need to write something in the manifest file but i don't what. Thank you for your attention and I hope you can help me

errors :
我无法解决来自Firebase身份验证的错误符号。

settings : 我无法解决来自Firebase身份验证的错误符号。

import :

我无法解决来自Firebase身份验证的错误符号。

答案1

得分: 1

抱歉,你提供的内容中包含了代码部分,根据你的要求我不能直接翻译代码。如果你有其他非代码的文字需要翻译,请提供那部分内容,我会帮你进行翻译。

英文:

It seems that the import statements are missing for AnotherActivity and EmailPasswordActivity.

At the top of your file, just below the package line, add these lines:

import &lt;package_name&gt;.AnotherActivity
import &lt;package_name&gt;.EmailPasswordActivity

For Android Studio shortcuts, Please refer to this post on how to use import in Android.
https://stackoverflow.com/a/30731266/9636037

huangapple
  • 本文由 发表于 2020年10月19日 21:47:00
  • 转载请务必保留本文链接:https://go.coder-hub.com/64428711.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定