Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7034343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:10:27+00:00 2026-05-28T01:10:27+00:00

I am having a problem getting a contact photo, the kind you see in

  • 0

I am having a problem getting a contact photo, the kind you see in the messaging app and new gmail notification. I have looked at a few example codes but nothing has worked for me, this is what I currently have

this should get the photo uri and turn it into a bitmap image to use or at least it seems

public static Bitmap getContactImage(long id,Context context){
    InputStream input = getPhoto(id,context);
    if(input == null){
        return null;
    }
    return BitmapFactory.decodeStream(input);
}

public static InputStream getPhoto(long contactId,Context context){
    Uri contactUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, contactId);
    Uri photoUri = Uri.withAppendedPath(contactUri, Contacts.Photo.CONTENT_DIRECTORY);
    InputStream in = null;
    try{
        in = context.getContentResolver().openInputStream(photoUri);
    }catch(FileNotFoundException e){
        Log.d(TAG, e.toString());
    }
    return in;
}

and this is how I call

long contactID = 0;
                Bitmap image = BitmapFactory.decodeResource(context.getResources(),R.drawable.ic_contact_picture);
                Cursor contact = context.getContentResolver().query(Data.CONTENT_URI,new String[] {Data.CONTACT_ID},Email.ADDRESS  + "='" + from + "'",null,null);
                if(contact.moveToFirst() && contact != null){
                    contactID = contact.getLong(0);
                    image = getContactImage(contactID,context);
                }

I get the contact id fine (checked by searching the number for the person querying against) but then it does not find the contact photo. I know there is a photo because I am testing it against myself to make sure and I have a contact photo so I dont know what else I should do.

I always find navigating the contact provider very troublesome because there is so much to it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T01:10:28+00:00Added an answer on May 28, 2026 at 1:10 am

    I got it, I did a query against the RAW_CONTACT_ID with the MIMETYPE and that gave me the photo I was looking for

    Cursor p = context.getContentResolver().query(Data.CONTENT_URI,new String[] {Photo.PHOTO},
                    Data.RAW_CONTACT_ID + "=" + contactId + " AND " + Data.MIMETYPE + "='" + Photo.CONTENT_ITEM_TYPE+"'"
                    ,null,null);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to unit testing/TDD and having problem getting my head certain aspects
I am having a problem getting an old Ruby on Rails 2 app that
having a problem getting my simple php email contact form working. No errors are
i am totally new to xquery and I am having problem getting the right
I am having problem getting my tooltip to work when using the jQuery load()
I am having problem getting this piece of code to run. The class is
I am having a problem getting Twitter Bootstrap Carousel to begin looping automatically at
I'm having a problem getting a simple ASP.NET webpage to display. The page contains
I'm having a problem getting a change event to register with the following code:
I'm having a problem getting XCode to deal with a particular file structure that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.