Please, I would like with my push retrieve the name of the email address, Info1 & info2 is OK, but infoGmail make error !
And Manifest is OK = AddPermission (android.permission.GET_ACCOUNTS)
B4X:
Sub Globals
Dim InfoText As EditText
Dim info1, info2, infoGmail As String
Dim PhoneName As Phone
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Main")
Dim r As Reflector
r.Target = r.RunStaticMethod("android.accounts.AccountManager", "get", _
Array As Object(r.GetContext), Array As String("android.content.Context"))
Dim accounts() As Object
accounts = r.RunMethod2("getAccountsByType","com.google", "java.lang.String")
For i = 0 To accounts.Length - 1
r.Target = accounts(i)
Dim accountName As String
accountName = r.GetField("name")
Log(accountName)
Next
infoGmail = accountName ' take name mail
info1 = (PhoneName.GetSettings("android_id"))
info2 =(PhoneName.Manufacturer)
InfoText.Text = info1 &"_"& info2 &"_"& infoGmail
If Regex.IsMatch("[\d\w]+",InfoText.Text) = False Then
ToastMessageShow("Erreur", True)
Return
End If
Register(InfoText.Text)
Else
Unregister(InfoText.Text)
End If
End Sub
And Manifest is OK = AddPermission (android.permission.GET_ACCOUNTS)
Last edited: