0

I am developing message send/receive application, and i need to get profile picture of phone number. Could any one please help me to get the profile picture of specific number?

Thanks in advance :)

Hossein Mobasher
  • 4,382
  • 5
  • 46
  • 73

1 Answers1

2
public static int getContactIDFromNumber(String contactNumber,Context context)
{
    contactNumber = Uri.encode(contactNumber);
    int phoneContactID = new Random().nextInt();
    Cursor contactLookupCursor = context.getContentResolver().query(Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,Uri.encode(contactNumber)),new String[] {PhoneLookup.DISPLAY_NAME, PhoneLookup._ID}, null, null, null);
        while(contactLookupCursor.moveToNext()){
            phoneContactID = contactLookupCursor.getInt(contactLookupCursor.getColumnIndexOrThrow(PhoneLookup._ID));
            }
        contactLookupCursor.close();

    return phoneContactID;
}

The above method returns contactId of specific phone number and refer this LINK to get profile picture from contactID.

Shankar Agarwal
  • 34,573
  • 7
  • 66
  • 64