How to get Photo from Contacts ( >= 1.6)

Put your problem here if it does not fit any of the other categories.

How to get Photo from Contacts ( >= 1.6)

Postby miguel » Thu Dec 31, 2009 1:51 am

Hi,

I'm trying to get the contact photo to put in a list view along with name and address. I've already done the code for putting the name and address but I don't know how to get the photo.

I've seen people is deprecated. So I'm using ContactMethods for the query:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. Cursor cursor = getContentResolver().query(
  2.  
  3.                         ContactMethods.CONTENT_URI,
  4.  
  5.                 null,
  6.  
  7.                 ContactMethods.KIND + "=" + Contacts.KIND_POSTAL, null, ContactMethods.DISPLAY_NAME);
Parsed in 0.030 seconds, using GeSHi 1.0.8.4


You can I get the uri for the contact photo? My application is to be compatible only with 1.6 and higher versions.

Thanks in advance
miguel
Junior Developer
Junior Developer
 
Posts: 12
Joined: Mon Sep 01, 2008 3:59 pm

Top

Postby jwei512 » Thu Dec 31, 2009 9:07 am

Hey Miguel,

Maybe my post on this will help?

http://thinkandroid.wordpress.com/2009/ ... pi-levels/

Let me know if you have any further questions.

- jwei
- jwei

http://thinkandroid.wordpress.com
Examples, Code, and Tutorials
jwei512
Senior Developer
Senior Developer
 
Posts: 135
Joined: Mon Jul 27, 2009 9:35 pm
Location: Palo Alto, CA

Postby miguel » Wed Jan 06, 2010 12:50 am

Thank you jwei512 ;) It help me a lot understanding what i was doing wrong. Here you can see the final result :D http://androidpt.com/images/fbfiles/ima ... 100103.png

One doubt, in 1.6 I don't have acess to ContactsContract. My application is for >= 1.6. To use ContactsContract I've to use 2.0 API, and is there a way that it can be compatible with 1.6 too?

Best regards, and thank you very much for the help.
miguel
Junior Developer
Junior Developer
 
Posts: 12
Joined: Mon Sep 01, 2008 3:59 pm

Postby jwei512 » Wed Jan 06, 2010 1:08 pm

Although I have not worked with this much myself... I have heard of this concept of "reflection" that allows you to make your apps more "backwards compatible"

http://developer.android.com/resources/ ... ility.html

You can read up on it there, although I probably can't give you anymore guidance than what the doc says.
- jwei

http://thinkandroid.wordpress.com
Examples, Code, and Tutorials
jwei512
Senior Developer
Senior Developer
 
Posts: 135
Joined: Mon Jul 27, 2009 9:35 pm
Location: Palo Alto, CA

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 8 guests