Languages

Menu
Sites
Language
Retrieve selected contact numbers and names

I have used this code from documentation link 

https://developer.tizen.org/help/topic/org.tizen.native.appprogramming/html/guide/app/appcontrol_contact.htm

It works and i can show the multiple contacts picker. My problem is that i cannot manage to get selected contacts name and phone.

I try OnAppControlCompleteResponseReceived to manage the selected contacts but the only value i can get is the key http://tizen.org/appcontrol/data/social/phone and a random number as a value.

.

Responses

5 Replies
hgw7

Try the following typecasting in OnAppControlCompleteResponseReceived():

pPickResult = const_cast < IList* > (dynamic_cast < const IList* > (pResultList->GetValue(String(L"http://tizen.org/appcontrol/data/social/phone"))));

You can then obtain information from this list:

for(int i=0;i<pPickResult->GetCount();i++)

{

         String *pValue = static_cast <String *> (pPickResult->GetAt(i));

         AppLog("phone %ls", pValue->GetPointer());

}

Alex Ashirov

Hi,

Do you know how to obtain contact's name of the selected contact?

hgw7

In contact appcontrol, i think only phone number, email and item id can be retrieved. 
Using "item_id" as the value for "http://tizen.org/appcontrol/data/social/result_type" key, the required information can be obtained with the help of Tizen::Social::Addressbook and Tizen::Social::Contact classes.


pPickResult = (Tizen::Base::Collection::IList*)pResultList->GetValue(String(L"http://tizen.org/appcontrol/data/social/item_id"));            

if (pPickResult != null)

{

for(int i=0;i<pPickResult->GetCount();i++)

{

String *pValue = static_cast<String *>(pPickResult->GetAt(i));

AppLog("ItemID %ls", pValue->GetPointer());

 

Addressbook* pAddressbook = AddressbookManager::GetInstance()->GetAddressbookN();

Contact* pContact = null;

String name;

float idf;

Float::Parse(pValue->GetPointer(), idf);

int id = static_cast <int> (idf);

pContact = pAddressbook->GetContactN(id);

pContact->GetValue(CONTACT_PROPERTY_ID_FIRST_NAME, firstName);

AppLog("name %ls", name.GetPointer());

}

}

Alex Ashirov

Thanks a lot!

Byron Gavras

Thank you  hgw7