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: 85
Registered: ‎06-22-2013
My Device: N/A
My Carrier: N/A
Accepted Solution

PIM contacts Phone Number ?

Hi Guys,

 

I am tring to retrive devices's contacts, and i did retrive all data but i cannot get the phone number 

bb::pim::contacts::ContactService *service = new bb::pim::contacts::ContactService();
bb::pim::contacts::ContactListFilters filters;
filters.setLimit(0);
List<bb::pim::contacts::Contact> contacts = service>contacts(filters);
	 for(int i=0 ; i < contacts.size() ; i++)
	 {

		 qDebug()<<"firstName<<contacts.at(i).firstName();
		 qDebug()<<"lastName"<<contacts.at(i).lastName();
		 qDebug()<<"phoneNumber===>"<<contacts.at(i)..phoneNumbers().size(); ///// size 0,   There is no phone numbers!!

       }

 

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

Re: PIM contacts Phone Number ?

Developer
Posts: 85
Registered: ‎06-22-2013
My Device: N/A
My Carrier: N/A

Re: PIM contacts Phone Number ?

ContactService * service  = new ContactService();
ContactListFilters filter;
QList<Contact>contacts = service->contacts(filter);
qDebug()<<"firstName"<<contacts.at(0).sortFirstName();
qDebug()<<"lastName"<<contacts.at(0).sortLastName();
qDebug()<<"phoneNumber===>"<<contacts.at(0).phoneNumbers().size();

 Phone Numbers Still 0 in Size !

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

Re: PIM contacts Phone Number ?

Are you sure contact 0 actually has phone numbers?


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: 85
Registered: ‎06-22-2013
My Device: N/A
My Carrier: N/A

Re: PIM contacts Phone Number ?

The problem was, i must get the contact by contactID

 

 

const Contact contact = service->contactDetails(contacts.at(0).id());
qDebug()<<"firstName"<<contact.sortFirstName();
qDebug()<<"lastName"<<contact.sortLastName());	 
qDebug()<<"phoneNumber"<<contact.phoneNumbers().first().value());
qDebug()<<"email"<<contact.emails().first().value());

 

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

Re: PIM contacts Phone Number ?

Yes I forgot about the id thing, I was looking at my code and wondering why it wasn't working for you, glad you fixed it.

 

	ContactService service;

    QList<Contact> contacts;

    ContactListFilters filter;
    contacts = service.contacts(filter);

    // Iterate over the list of contact IDs
    foreach (const Contact &idContact, contacts) {
        // Fetch the complete details for this contact ID
        const Contact contact = service.contactDetails(idContact.id());

        qDebug() << contact.id() << contact.firstName() << contact.lastName();

        if (!contact.phoneNumbers().isEmpty())
        	qDebug() << contact.phoneNumbers().first().value();

        if (!contact.emails().isEmpty())
        	qDebug() << contact.emails().first().value();
    }

 

 

 


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.