FA GOOGLE LoginAnonymous-MainActivity-MainLogic

Advertisements
 if (currentUser == null){                                       //check if the user is new then signIn anonymously
                mAuth.signInAnonymously().                                 //.signInAnonymously is a method provided by Firebase
                    addOnCompleteListener(new OnCompleteListener<AuthResult>() {        //insert a Listener that listen
                        @Override
                        public void onComplete(@NonNull Task<AuthResult> task)          // insert a method that will executes when the process is completed
                        {
                            if (task.isSuccessful())                    // check the required task is completed successfully
                            {
                                loginMessage.setVisibility(View.VISIBLE);       //visible the text
                                progressBar.setVisibility(View.INVISIBLE);       //inVisible the progressBar
                            }
                        }
                    })
                        .addOnFailureListener(new OnFailureListener() {         //if the signin failed
                            @Override
                            public void onFailure(@NonNull Exception e) {
                                Log.e("TAG",e.getMessage());            //return error in logs
                            }
                        });
                }