0% found this document useful (0 votes)
12 views

Addnumbers Snippet

This JSON document describes code to pick a contact from the device contacts and retrieve the contact's name, photo thumbnail, and phone number. The code uses cursors to query the device contacts provider and retrieve the required contact information based on a contact ID.

Uploaded by

Kasturi Pathak
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Addnumbers Snippet

This JSON document describes code to pick a contact from the device contacts and retrieve the contact's name, photo thumbnail, and phone number. The code uses cursors to query the device contacts provider and retrieve the required contact information based on a contact ID.

Uploaded by

Kasturi Pathak
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

if (resultCode == RESULT_OK) {

if (requestCode == CONTACT_PICK_CODE) {
// contactTV.setText("");

Cursor cursor1, cursor2;

Uri uri = data.getData();

cursor1 = getContentResolver().query(uri, null, null, null, null);

if (cursor1.moveToFirst()) {
String ContactId =
cursor1.getString(cursor1.getColumnIndex(Contacts._ID));
String ContactName =
cursor1.getString(cursor1.getColumnIndex(Contacts.DISPLAY_NAME));
String ContactThumbnail =
cursor1.getString(cursor1.getColumnIndex(Contacts.PHOTO_THUMBNAIL_URI));
String idResults =
cursor1.getString(cursor1.getColumnIndex(Contacts.HAS_PHONE_NUMBER));

int idResultHold = Integer.parseInt(idResults);


if (idResultHold == 1) {
cursor2 =
getContentResolver().query(CommonDataKinds.Phone.CONTENT_URI, null,
CommonDataKinds.Phone.CONTACT_ID + " = " + ContactId, null, null);

while (cursor2.moveToNext()) {
String ContactNumber =
cursor2.getString(cursor2.getColumnIndex(CommonDataKinds.Phone.NUMBER));

Log.d("contact", ContactNumber);
//contactTV.append("ID:"+con)
}

}
}
}

You might also like