Android Question contact util cant read phone list on CM12 (5.1.1.)

Tayfur

Well-Known Member
Licensed User
Longtime User
Hello;
I used @Erel 's contact utils code.
https://www.b4x.com/android/forum/threads/contactsutils-draft-version.30758/
Your code is works. I checked many times .

Now; My old phone samsung S2 GTI9100 change/update android 5.1.1. CyanogenMod.
After my old codes dosent work for Contact list.

I checked it. and Code read only 1 record. this record is "Google contact"
Code cant read other "Local phone account contact"
I looked with 3rd party APP on all contacts (AirDroid)

do you have any idea????

1.png
2.png
 
Last edited:

Tayfur

Well-Known Member
Licensed User
Longtime User
Hard to say. Note that the latest version of ContactsUtils is available here: https://www.b4x.com/android/forum/t...ad-write-access-to-the-stored-contacts.30824/

Try to use Contacts or Contacts2 from the Phone library and see whether it works.

Thank you for feedback.
I will try . I saw same result only 2 records.

I change little code

B4X:
log(cu.FindAllContacts(FALSE).size) ' >>> return 146
For Each c As cuContact In cu.FindAllContacts(FALSE) '<< is not TRUE
        lstContacts.AddSingleLine2(c.DisplayName, c)
   Next

why visible change ??? How is fix it??
 
Upvote 0

Tayfur

Well-Known Member
Licensed User
Longtime User
@Erel

I cheked with phone library.

Result is very intresting!!!

I cheked in phone menu for persons:
Phone records: 109pcs
Whatsapp: 71 pcs

I cant calculate and match all results?????????????

B4X:
dim cnt as Contacts
dim cnt2 as Contacts2
Dim x As List
    x.Initialize
    x= cnt.GetAll
    Log(x.Size&"--pcs") '>>> 83pcs
    x.Clear
    x=cnt2.GetAll(True,False)
    Log(x.Size&"--adet") '>>> 198pcs
    x.Clear
    x=cnt2.GetContactsByQuery("",Null,True,False)'>>> 198 Pcs
    Log(x.Size&"--adet")
   cu.Initialize ' your contacts utils class
   Log(cu.FindAllContacts(True).Size&"--pcs")'>>>0 pcs
    Log(cu.FindAllContacts(False).Size&"--pcs")'>>> 141pcs
 
Upvote 0

Tayfur

Well-Known Member
Licensed User
Longtime User
Visible means that the in_visible_group parameter is set to 1. You can see it in the source code. This usually means that it is a contact that was added by the user.

Contacts is based on an old and deprecated API. Contacts2 is based on the same API as ContactsUtils.


I checked empty phone records. Result is same (109 pcs) like on phone list.

in_visible_group parameter issue...
is it posisible, all update contact list from external recpurse when phone updating.????

B4X:
dim cnt as Contacts
dim cnt2 as Contacts2
Dim x As List
    x.Initialize
    x= cnt.GetAll
    Log(x.Size&"--pcs") '>>> 83pcs
    x.Clear
    x=cnt2.GetAll(True,False)
    Log(x.Size&"--adet") '>>> 198pcs
    x.Clear
    x=cnt2.GetContactsByQuery("",Null,True,False)'>>> 198 Pcs
    Log(x.Size&"--adet")
   cu.Initialize ' your contacts utils class
   Log(cu.FindAllContacts(True).Size&"--pcs")'>>>0 pcs
    Log(cu.FindAllContacts(False).Size&"--pcs")'>>> 141pcs
    x.Clear
    Dim say As Int=0
    For Each c As cuContact In cu.FindAllContacts(False)
        x.Clear
        x=cu.GetPhones(c.Id)
        If x.Size>0 Then
            lstContacts.AddSingleLine2(c.DisplayName, c)
            say=say+1
        End If
    Next
    Log(say&" adet") ' <<< 109 pcs...Same my contact list
[/QUOTE]
 
Last edited:
Upvote 0
Top