ContactsUtils - draft version

Erel

Administrator
Staff member
Licensed User
The ContactsUtils class allows you to read and modify the stored contacts.

The current version is an early beta. There are still some features missing.

However you can already play with it and go over the code.

It requires the new ContentResolver library: [library] ContentResolver

Types:
B4X:
Type cuContact (Id As Long, DisplayName As String)
Type cuEmail (Email As String, EmailType As String)
Type cuPhone (Number As String, PhoneType As String)
All the Findxxx methods return a List with cuContact items:
B4X:
Public Sub FindContactsByName(Name As String, Exact As Boolean, VisibleOnly As Boolean) As List

Public Sub FindContactsByMail(Mail As String, Exact As Boolean, VisibleOnly As Boolean) As List


Public Sub FindContactsByNotes(Note As String, Exact As Boolean, VisibleOnly As Boolean) As List

Public Sub FindContactsByPhone(PhoneNumber As String, Exact As Boolean, VisibleOnly As List

Public Sub FindContactsByStarred(Starred As Boolean) As List

Public Sub FindContactsWithPhotos As List
Get fields:
B4X:
'Returns a List with cuEmail items.
Public Sub GetEmails(Id As Long) As List
   
'Returns a List with cuPhone items.
Public Sub GetPhones(id As Long) As List
   
'Returns the note field.
Public Sub GetNote(id As Long) As String
   
'Returns the thumbnail photo of the given contact. Returns an uninitialized bitmap if no photo is available.
Public Sub GetPhoto(Id As Long) As Bitmap
Set / Add methods:
B4X:
'Sets the note field of the given id.
Public Sub SetNote(Id As Long, Note As String)

'Adds an email field to the given contact id.
Public Sub AddEmail(Id As Long, Email As String, EmailType As String)
More methods will be available in the final version.
It should also be relatively simple to extend the code.
 

Attachments

Theera

Well-Known Member
Licensed User
Hi Erel,
I've test with emulator and don't see what in log tab. How to test?
 

Theera

Well-Known Member
Licensed User
You should change the code in the main activity so that it will match any of the contacts.
Hi Erel,
I've already used cu.addEmail() and log(cu.getEmails(1)) ,but it returned empty array. I make something wrong.
 

Attachments

Theera

Well-Known Member
Licensed User
Thank you Erel,I'm understand now.
 
Top