I have the following method:
private void recoverPassword() {
FirebaseAuth mAuth = FirebaseAuth.getInstance();
mAuth.sendPasswordResetEmail("[email protected]").addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (!task.isSuccessful()) {
Exception e = task.getException();
System.out.println(e.toString());
}
});
}
And I keep getting Android Studio warning:
Result of 'getException()' not thrown
How can I rewrite the snippet above to get rid of that warning?
Thanks!
Add a SuppressWarnings
annotation to the method:
@SuppressWarnings("ThrowableResultOfMethodCallIgnored")
@Override
public void onComplete(@NonNull Task<Void> task) {
if (!task.isSuccessful()) {
Exception e = task.getException();
System.out.println(e.toString());
}
}
Android Studio will help you with this:
getException()
Alt-Enter
Inspection 'Throwable result of method call ignored' options
Suppress for Method
(or any other option you prefer)If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With