'this code doesn't require any permission.
Sub Globals
Private ion As Object
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("1")
Dim jo As JavaObject
jo.InitializeStatic("android.accounts.AccountManager")
StartActivityForResult(jo.RunMethod("newChooseAccountIntent", Array(Null, Null, Array As String("com.google"), Null, Null, Null, Null)))
Wait For ion_Event (MethodName As String, Args() As Object)
If Args(0) = -1 Then 'resultCode = RESULT_OK
Dim i As Intent = Args(1)
Log(i.GetExtra("authAccount"))
End If
End Sub
Sub StartActivityForResult(i As Intent)
Dim jo As JavaObject = GetBA
ion = jo.CreateEvent("anywheresoftware.b4a.IOnActivityResult", "ion", Null)
jo.RunMethod("startActivityForResult", Array As Object(ion, i))
End Sub
Sub GetBA As Object
Dim jo As JavaObject
Dim cls As String = Me
cls = cls.SubString("class ".Length)
jo.InitializeStatic(cls)
Return jo.GetField("processBA")
End Sub