1. Download our Official Android App: Forums for Android!

How to get contact's photo in appwidget?

Discussion in 'Introductions' started by intsurfer, Oct 30, 2010.

  1. intsurfer

    intsurfer Lurker
    Thread Starter
    Rank:
    None
    Points:
    26
    Posts:
    9
    Joined:
    Oct 30, 2010

    Oct 30, 2010
    9
    1
    26
    Oracle Developer
    Nizhniy Novgorod, Russia
    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...
    Rank:
    None
    Points:
    843
    Posts:
    19,535
    Joined:
    Jul 9, 2010

    Jul 9, 2010
    19,535
    4,045
    843
    Male
    Engineer
    'neath a cactus
  3. Steven58

    Steven58 Reformed PH
    Rank:
     #4
    Points:
    3,933
    Posts:
    32,959
    Joined:
    Feb 19, 2010

    Feb 19, 2010
    32,959
    25,351
    3,933
    Male
    Welcome to Android Forums!
     

Share This Page

Loading...