英文:
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);
}
}
});
}
我认为我需要在清单文件中做一些设置,但我不知道具体是什么。感谢您的关注,希望您能帮助我。
英文:
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,"U Signed In successfully",Toast.LENGTH_LONG).show();
startActivity(new Intent(this,AnotherActivity.class));
}else {
Toast.makeText(this,"U Didnt signed in",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<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
// Sign in success, update UI with the signed-in user's information
Log.d("success", "signInWithEmail:success");
FirebaseUser user = mAuth.getCurrentUser();
updateUI(user);
} else {
// If sign in fails, display a message to the user.
Log.w("failed", "signInWithEmail:failure", task.getException());
Toast.makeText(EmailPasswordActivity.this, "Authentication failed.",
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
import :
答案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 <package_name>.AnotherActivity
import <package_name>.EmailPasswordActivity
For Android Studio shortcuts, Please refer to this post on how to use import in Android.
https://stackoverflow.com/a/30731266/9636037
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论