我有以下方法:
private void recoverPassword() {
FirebaseAuth mAuth = FirebaseAuth.getInstance();
mAuth.sendPasswordResetEmail("mail@example.com").addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (!task.isSuccessful()) {
Exception e = task.getException();
System.out.println(e.toString());
}
});
}
我一直收到Android Studio警告:
&#39; getException()&#39;的结果没有抛出
如何重写上面的代码片段以消除警告?
谢谢!
答案 0 :(得分:10)
在方法中添加SuppressWarnings
注释:
@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
@Override
public void onComplete(@NonNull Task<Void> task) {
if (!task.isSuccessful()) {
Exception e = task.getException();
System.out.println(e.toString());
}
}
Android Studio将为您提供帮助:
getException()
Alt-Enter
Inspection 'Throwable result of method call ignored' options
Suppress for Method
(或您喜欢的任何其他选项)