Hi,
I'm using this code to pick phone numbers from Contacts.
It worked great if contact only have 1 phone number. I tried another app which can list all phone numbers, just like screen shot below. How can I archive it? Thank you.
I'm using this code to pick phone numbers from Contacts.
B4X:
Sub Activity_Click
Dim i As Intent
i.Initialize(i.ACTION_PICK, "content://com.android.contacts/contacts")
StartActivityForResult(i)
End Sub
Sub ion_Event (MethodName As String, Args() As Object) As Object
If Args(0) = -1 Then 'resultCode = RESULT_OK
Dim i As Intent = args(1)
Dim id As String = i.GetData.SubString(i.GetData.LastIndexOf("/") + 1)
Dim cu As ContactsUtils
cu.Initialize
Log(cu.GetNameFromId(id))
End If
Return Null
End Sub
B4X:
Public Sub GetNameFromId (id As String) As String
Dim crsr As Cursor = cr.Query(dataUri, Array As String("contact_id", "display_name"), "contact_id = ?", _
Array As String(id), "")
Dim name As String
If crsr.RowCount = 0 Then
Log("Contact not found: " & id)
Else
crsr.Position = 0
name = crsr.GetString2(1)
End If
crsr.Close
Return name
End Sub
It worked great if contact only have 1 phone number. I tried another app which can list all phone numbers, just like screen shot below. How can I archive it? Thank you.