Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
Posts: 29
Registered: ‎04-02-2013
My Device: BlackBerry Z10
My Carrier: Telus

Search Contacts

I am having some trouble retrieving contacts using the PIM api's and was hoping to get some help.

 

I want to pull a list of all contacts on the device. To do this I tried using a ContactListFilter with no filters and this returned only 20 items. When I set the filter limit to 200 items it returned all 91 items from gmail but nothing else. There are a total of 500+ contacts listed on my device, but I cannot seem to access them using ContactListFilter or ContactSearchFilter.

 

Please Advise.

 

This snippet of code only displays 20 items.

 

void ApplicationUI::getContacts(){
	ContactListFilters filters;

	QList<Contact> contactList = ContactService().contacts(filters);

	foreach (const Contact &idContact, contactList) {
		//const Contact contact = m_contactService->contactDetails(idContact.id());
		qDebug() << idContact.displayName() << " ";
	}
}

 

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Search Contacts

[ Edited ]

Try setting filters.setLimit(200);

 

Or the number you are expecting.

 

[Edit] Sorry must have skipped past the part you said you had done this.

 

There does seem to be as default limit of 20


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: Search Contacts

What you can do is read the limit from the return of contacts and then pass that as an offset to the next iteration if the maximum size has not been breached.


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 29
Registered: ‎04-02-2013
My Device: BlackBerry Z10
My Carrier: Telus

Re: Search Contacts

When I do that it still only returns the 91 contacts linked to my Gmail account. I am unable to access the Twitter/Facebook/LinkedIn accounts on the device.
Retired
Posts: 749
Registered: ‎12-16-2008
My Device: BlackBerry Z30
My Carrier: Bell

Re: Search Contacts

Unfortunately you specifically cannot access the contacts for those social apps.

Paul Bernhardt
Application Development Consultant
BlackBerry
@PBernhardt

Did this answer your question? Please accept this post as the solution.
Found a bug? Report it to the Developer Issue Tracker