Skip to content Skip to sidebar Skip to footer

Get Rawcontact Photo

I know it is possible to get the contact's photo using something like: public InputStream getContactPhotoInputStream() throws IOException { Uri uri = Uri.withAppendedPath(C

Solution 1:

After a lot of digging around, looking android's source code exhaustively, I found a way to get the image from a raw contact.

Using Android's native code to get it, I did my own solution (my problem was getting the raw contact's image URI, I couldn't find a way to get it). So from here public static boolean savePhotoFromUriToUr I did this:

public InputStream getBitmapFromUri(String rawContactId)throws FileNotFoundException {

        finalUriphotoUri= Uri.withAppendedPath(
                ContentUris.withAppendedId(RawContacts.CONTENT_URI, Long.valueOf(rawContactId)), RawContacts.DisplayPhoto.CONTENT_DIRECTORY);
        finalInputStreamimageStream= contentResolver.openInputStream(photoUri);

        return imageStream;
}

So here it is, how to get the raw contact's photo.

Post a Comment for "Get Rawcontact Photo"