Hi all :sign0085:
Going crazy trying to addapt a code found on the forum to my needs.
Concerning Contacts, and I want to return the Contacts Mobile Number.
The original syntax returned the default phone number.
My code returns "2" for all contacts.
Can anyone give me an hint of what I'm doing wrong?
Regards
Bergapappa
Going crazy trying to addapt a code found on the forum to my needs.
Concerning Contacts, and I want to return the Contacts Mobile Number.
The original syntax returned the default phone number.
My code returns "2" for all contacts.
Can anyone give me an hint of what I'm doing wrong?
B4X:
Sub Button1_Click
Dim Contacts2 As Contacts2
Dim list1 As List
list1 = Contacts2.GetAll(False,False)
Dim listOfNames As List
listOfNames.Initialize
For i = 0 To list1.Size - 1
Dim c As Contact
c = list1.Get(i)
If c.DisplayName.IndexOf("@") = -1 Then
listOfNames.Add(c.DisplayName)
End If
Next
Dim res As Int
res = InputList(listOfNames, "Choose contact", -1)
If res <> DialogResponse.CANCEL Then
Dim name As String
name = listOfNames.Get(Res)
Dim c As Contact
For i = 0 To list1.Size
c = list1.Get(i)
If c.DisplayName = name Then Exit
Next
If c.PHONE_MOBILE > 0 Then 'c.PhoneNumber.Length >
edtNum.Text = c.PHONE_MOBILE
Else
edtNum.Text = "No mobile number"
End If
End If
End Sub
Bergapappa
Last edited by a moderator: