Android Question FirebaseAuth - CurrentUser not initialized in Activity_Resume

LucaMs

Expert
Licensed User
Longtime User
I'm creating an Activity to allow an user custom registration (simply nick name and pw) or by Google sign.

If the user choses Google, I call mFirebaseAuth.SignInWithGoogle; even if he selects a his google account, in the Activity_Resume CurrentUser results not yet initialized. I don't think that I should add a Sleep(x) in the Resume, because x should have an arbitrary value, not efficient (and probably this would not work).

How should I do?


Thank you
 
Last edited:

LucaMs

Expert
Licensed User
Longtime User
That's good.

What exactly is the question? You want to handle the case where SignedIn is not raised because the user cancelled the log in?
You will need to use Sleep for this.
Not exactly (meanwhile I decided to use only a custom registration, but I need anyway to solve, for future apps).

In the Resume I call a routine which sets the visibility of some views (to select the type of registration or login, edittexts for nick, pw, email, confirmations...) based on the "state of the activity":

B4X:
Sub Activity_Resume
    If mRegisState = REGIS_STATE_G_SIGNIN Then
         If mFireBaseAuth.CurrentUser.IsInitialized = False Then
            mRegisState = REGIS_STATE_FIRST_SEL
        End If
    End If
    SetViews
End Sub

If user choses to sign in with Google, there are two possible cases: he selects a google account or "aborts", touching on the screen.

mFireBaseAuth.CurrentUser.IsInitialized will be false in both cases, because the SignedIn event will raise only after.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
You will need to use Sleep here to allow the sign in event to be raised before Activity_Resume completes.
It is what I wrote:
I don't think that I should add a Sleep(x) in the Resume, because x should have an arbitrary value, not efficient (and probably this would not work).

but you cannot know how much time is needed and the visual experience for the user will be very bad.
 
Upvote 0
Top