Android Question Write file after google signin

Stefano Di Chiano

Active Member
Licensed User
Hi,
I'm trying to write a file with the email of the google account the user signs in with. The problem is that if I try to write the file before the signinwithgoogle sub has ended, I get an error.
So I wrote this:
B4X:
Starter.auth.SignInWithGoogle 'google login
Sleep(10000)
WriteFile(Starter.auth.CurrentUser.Email)
WriteFile is a sub I wrote.
What can I use instead of sleep to write the file in the exact moment after SignInWithGoogle has ended?
I tried with Wait For but I couldn't get the right syntax.
 
After you started the SigninProces your app goes to background.
When the signin is finished your activity will be resumed (running again through Activity_create

From the Tutorial
B4X:
Sub Activity_Create(FirstTime As Boolean)
   If FirstTime Then
     auth.Initialize("auth")
   End If
   Activity.LoadLayout("1")
   If auth.CurrentUser.IsInitialized Then Auth_SignedIn(auth.CurrentUser) ' here the user should be initialized after login and your  sub Auth_SignedIn is called.
End Sub

Sub btnSignIn_Click
   auth.SignInWithGoogle
End Sub

Sub btnSignOut_Click
   auth.SignOutFromGoogle
   lblName.Text = "Goodbye!"
End Sub

Sub Auth_SignedIn (User As FirebaseUser)
   Log("SignedIn: " & User.DisplayName)
   lblName.Text = "Hello: " & User.DisplayName
   ' Write the File here now..
End Sub
 
Upvote 0
Back
Top