1. Are you ready for the Galaxy S20? Here is everything we know so far!

How to get contact's photo in appwidget?

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

  1. intsurfer

    intsurfer Lurker
    Thread Starter

    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!
     



    1. Download the Forums for Android™ app!


      Download

       
  2. Martimus

    Martimus One bite at a time...

  3. Steven58

    Moderator

    Welcome to Android Forums!
     
Loading...

Share This Page

Loading...