How to get contact's photo in appwidget?


Last Updated:

  1. intsurfer

    intsurfer Member This Topic's Starter

    Joined:
    Oct 30, 2010
    Messages:
    9
    Likes Received:
    1
    Hi!
    I googled for some days and tested quite a few scripts to get contact's photo...
    My last version:
    public static Bitmap loadContactPhoto(Context context, String myph) {
    ContentResolver cr=(ContentResolver) context.getContentResolver();
    InputStream input = ContactsContract.Contacts.openContactPhotoInputStream(cr, Uri.parse("tel:" + myph));
    return BitmapFactory.decodeStream(input);
    }

    The main problem is to define ContentResolver... If I use image from drawable, everything is ok!

    remoteViews.setImageViewResource(R.id.ConButton,R.drawable.ConPhoto);

    But I'd like to use contact's photo... Help please!
     

    Advertisement
  2. Martimus

    Martimus One bite at a time... Moderator

    Joined:
    Jul 9, 2010
    Messages:
    19,535
    Likes Received:
    4,045
  3. Steven58

    Steven58 Reformed PH VIP Member

    Joined:
    Feb 19, 2010
    Messages:
    32,920
    Likes Received:
    25,271
    Welcome to Android Forums!
     

Share This Page

Loading...