ContactsUtils - draft version

Discussion in 'Android Questions' started by Erel, Jul 4, 2013.

  1. Erel

    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:
    Code:
    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:
    Code:
    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:
    Code:
    '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:
    Code:
    '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.
     

    Attached Files:

  2. Theera

    Theera Well-Known Member Licensed User

    Hi Erel,
    I've test with emulator and don't see what in log tab. How to test?
     
  3. Erel

    Erel Administrator Staff Member Licensed User

    Have you added any contacts? You should change the code in the main activity so that it will match any of the contacts.
     
  4. Theera

    Theera Well-Known Member Licensed User

    Hi Erel,
    I've already used cu.addEmail() and log(cu.getEmails(1)) ,but it returned empty array. I make something wrong.
     

    Attached Files:

  5. Erel

    Erel Administrator Staff Member Licensed User

    1 is not a valid Id. You should get the Id with one of the Find methods.
     
  6. Erel

    Erel Administrator Staff Member Licensed User

  7. Theera

    Theera Well-Known Member Licensed User

    Thank you Erel,I'm understand now.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice