Ad

Is It Really Necessary To Remove The Complete Listener Firebase Authentication?

As my title says, is it necessary to remove the complete listener or to pass this as the first parameter in order to remove the complete listener attached to the signInWithCredential function?

auth.signInWithCredential(credential).addOnCompleteListener(this, ...)

If yes, how can I remove the listener without passing this?

Ad

Answer

It's not necessary to remove the listener. In fact, it's not possible to remove a listener that was added to a Task returned by an asynchronous operation. By passing this (which I assume means your current Activity), you are telling the Task API that you don't want to handle the result of the sign in after the activity is destroyed.

Ad
source: stackoverflow.com
Ad