Sub updateFbProfile()
Dim tmpGoogleDisplayName As String = ""
Dim tmpGooglePhotoUrl As String = ""
Try
'Retrieve user's public Google profile
Dim jo As JavaObject = FBAuth.CurrentUser
Dim sProviderData As List = jo.RunMethod("getProviderData", Null)
For Each item In sProviderData
Dim jo2 As JavaObject = item
If jo2.RunMethod("getProviderId", Null) == "google.com" Then
'données du profil Google
tmpGoogleDisplayName = jo2.RunMethod("getDisplayName", Null)
tmpGooglePhotoUrl = jo2.RunMethod("getPhotoUrl", Null)
End If
Next
Catch
'exit
Return
End Try
'Updates the FB profile if necessary
If (tmpGoogleDisplayName <> "" And tmpGoogleDisplayName <> FBAuth.CurrentUser.DisplayName) _
Or (tmpGooglePhotoUrl <> "" And tmpGooglePhotoUrl <> FBAuth.CurrentUser.PhotoUrl) Then
Try
Dim joUri As JavaObject
Dim newPhotoUri As Object = joUri.InitializeStatic("android.net.Uri").RunMethodJO("parse",Array(tmpGooglePhotoUrl))
Dim joBuilder As JavaObject
joBuilder.InitializeNewInstance("com.google.firebase.auth.UserProfileChangeRequest.Builder", Null)
joBuilder.RunMethodJO("setDisplayName", Array(tmpGoogleDisplayName))
joBuilder.RunMethodJO("setPhotoUri", Array(newPhotoUri))
Dim profileUpdates As Object = joBuilder.RunMethod("build", Null)
Dim jo As JavaObject = FBAuth.CurrentUser
Dim task As JavaObject = jo.RunMethod("updateProfile", Array(profileUpdates))
Do While task.RunMethod("isComplete", Null) = False
Sleep(100)
Loop
Log("Profile updates :-)")
Catch
'exit
Return
End Try
End If
End Sub