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: 777
Registered: ‎07-21-2012
My Device: 9810
My Carrier: 0

How to get photos of contacts list if they exit

Hello

 

can you please tell me how to get contacts phots and their name  from contact list..?

Developer
Posts: 571
Registered: ‎04-11-2009
My Device: BB 10 Dev Alpha

Re: How to get photos of contacts list if they exit

Hi,

 

class <bb/pim/contacts/ContactService> # contacts () will return you QList of Contact.

class <bb/pim/contacts/Contact> # firstName()/ lastName ()/ displayName() will return you the name.
class <bb/pim/contacts/Contact> # photos () will give you QList of ContactPhoto.
Now, <bb/pim/contacts/ContactPhoto> # smallPhoto ()/ largePhoto ()/ originalPhoto () will you return the path of Image of this Contact.

 

At last, using File Connection you can get bytes of Image and respectively the Image.

Regards,
Kanak Sony
------------------------------------------------------------------------------------------
http://dodevelopnshare.wordpress.com/ | http://www.linkedin.com/profile/view?id=188131481&trk=tab_pro
Developer
Posts: 777
Registered: ‎07-21-2012
My Device: 9810
My Carrier: 0

Re: How to get photos of contacts list if they exit

Hello madam , 

 

Thanks  for reply. actually i am begineer in c++ field i saw addressbook example in blackberry 10. There they show only fiest name and last name .what i can that code so that i can know his number and image.

 

i want to learn only so i only check in console.so 

here is that example

https://github.com/blackberry/Cascades-Samples/tree/master/addressbook/src

 

I think i want to change something on ContactViewer.cpp

 

* Copyright (c) 2012 Research In Motion Limited.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include "ContactViewer.hpp"

#include <bb/pim/contacts/Contact>

using namespace bb::pim::contacts;

//! [0]
ContactViewer::ContactViewer(ContactService *service, QObject *parent)
    : QObject(parent)
    , m_contactService(service)
    , m_contactId(-1)
{
    // Ensure to invoke the contactsChanged() method whenever a contact has been changed
    connect(m_contactService, SIGNAL(contactsChanged(QList<int>)), SLOT(contactsChanged(QList<int>)));
}
//! [0]

//! [1]
void ContactViewer::updateContact()
{
    // Store previous values
    const QString oldFirstName = m_firstName;
    const QString oldLastName = m_lastName;

********** const QDateTime oldBirthday = m_birthday; const QString oldEmail = m_email; // Fetch new values from persistent storage const Contact contact = m_contactService->contactDetails(m_contactId); m_firstName = contact.firstName(); m_lastName = contact.lastName(); ***************here iwrite **
qDebug<< contact.photo(); m_birthday = QDateTime(); const QList<ContactAttribute> dateAttributes = contact.filteredAttributes(AttributeKind::Date); foreach (const ContactAttribute &dateAttribute, dateAttributes) { if (dateAttribute.subKind() == AttributeSubKind::DateBirthday) m_birthday = dateAttribute.valueAsDateTime(); } m_email.clear(); const QList<ContactAttribute> emails = contact.emails(); if (!emails.isEmpty()) m_email = emails.first().value(); // Check whether values have changed if (oldFirstName != m_firstName) emit firstNameChanged(); if (oldLastName != m_lastName) emit lastNameChanged(); if (oldBirthday != m_birthday) emit birthdayChanged(); if (oldEmail != m_email) emit emailChanged(); } //! [1] //! [2] void ContactViewer::contactsChanged(const QList<int> &contactIds) { /** * Call updateContact() only if the contact we are currently displaying * has been changed. */ if (contactIds.contains(m_contactId)) updateContact(); } //! [2] //! [3] void ContactViewer::setContactId(ContactId contactId) { if (m_contactId == contactId) return; m_contactId = contactId; // Trigger a refetch of the contact for the new ID updateContact(); } //! [3] QString ContactViewer::firstName() const { return m_firstName; } QString ContactViewer::lastName() const { return m_lastName; } QDateTime ContactViewer::birthday() const { return m_birthday; } QString ContactViewer::formattedBirthday() const { if (!m_birthday.isValid()) return tr("n/a"); else return m_birthday.date().toString(); } QString ContactViewer::email() const { return m_email; }

 

Hello

can you please check if  write contact.photo() or contact.phoneNumber it show error .

 

Is there any thing i have to change . some thing in pro file or in header file .i want to show in console.

Developer
Posts: 777
Registered: ‎07-21-2012
My Device: 9810
My Carrier: 0

Re: How to get photos of contacts list if they exit

Basic tutorial for c++ used in blackberry 10.I don't qml. i need c++ coding book

Developer
Posts: 16,985
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: How to get photos of contacts list if they exit


ravi1989 wrote:

Basic tutorial for c++ used in blackberry 10.I don't qml. i need c++ coding book


i would guess there are plenty of c++ books available

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter