Appwidgets and SDK 2.0 ContactContracts

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Appwidgets and SDK 2.0 ContactContracts

Postby xgeraldx » Mon Nov 16, 2009 8:08 pm

My Appwidget has an ImageButton that I'm trying to assign a contact photo for the image. I did an application test and it worked fine, but when I implement it in the Appwidget, it doesn't set the image. Does anyone know how I can pull the contact image using the ContactContracts and make a drawable or .png out of it?

Here is the code that I'm using to set the image on the imagebutton in the Appwidget:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. RemoteViews remoteView = new RemoteViews(context.getPackageName(),R.layout.widget);
  2.  
  3. Uri uri = Uri.withAppendedPath( ContactsContract.Contacts.CONTENT_URI,
  4.  
  5.         config.getString("contactId", "1") );
  6.  
  7. uri = Uri.withAppendedPath( uri,        ContactsContract.Contacts.Photo.CONTENT_DIRECTORY);
  8.  
  9. remoteView.setImageViewUri(R.id.imgContactBtn, uri);
Parsed in 0.032 seconds, using GeSHi 1.0.8.4
xgeraldx
Freshman
Freshman
 
Posts: 4
Joined: Fri Sep 26, 2008 3:58 pm

Top

Postby xgeraldx » Tue Nov 17, 2009 5:02 am

Ok, I figured it out. For some reason I was calling remoteviews again after I already set the variable. It works now.
xgeraldx
Freshman
Freshman
 
Posts: 4
Joined: Fri Sep 26, 2008 3:58 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: Majestic-12 [Bot] and 7 guests