Android Question Google default sign-in button

islander

Member
Licensed User
Hi,
Is there a way with b4a to have the default sign in with google button (the one from com.google.android.gms.common.SignInButton) in an activity? Either as a new button or by transforming an existing button's (like designer script buttons) appearance into one.

In java it'd be done like how it's described here https://developers.google.com/identity/sign-in/android/sign-in (under Add the Google Sign-In button to your app)

And if there's a way to have that default sign-in button, how would I also customize it (like size and scope, in java it'd be calling setSize and setScopes like described in the link above)?

Thank you very much.
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

Marcus Araujo

Member
Licensed User
Longtime User
I have been looking for an answer for this, too and ended up creating a workaround, by creating the button in run time:

B4X:
Activity.AddView(getGoogleSigninButton, 16dip, 50%y + 16dip, 100%x - 32dip, 40dip)

And handling the click event:
B4X:
Sub SignInButton_Click(viewTag As Object)
    MsgboxAsync("Click", "")
End Sub

This is the Sub I created:
B4X:
' Event: <code> Sub SignInButton_Click(viewTag as Object) </code>
Sub getGoogleSigninButton As View
    Dim r As Reflector 
    Dim obj As Object = r.CreateObject2("com.google.android.gms.common.SignInButton", Array(r.GetContext), Array As String("android.content.Context"))
    r.Target = obj
    r.SetOnClickListener("SignInButton_Click")
    Return obj
End Sub
 
Upvote 0
Top