title: How can I load an image from a url into an android remote view for a widget
body: <p>I have an image url I parse form json that I want to load into an android widget onto the homescreen. Right now I am trying to do it this way but its wrong:</p>
  
  <pre><code>ImageDownloadTask imageD = new ImageDownloadTask(image);
              views.setImageViewBitmap(R.id.image, imageD.execute(image));
  </code></pre>
  
  <p>image is a string holding a url to an image that needs to be downloaded and I am trying to set it to R.id.image</p>
  
  <p>I found another stack question and tried this as a result:</p>
  
  <pre><code>views.setBitmap(R.id.image, "setImageBitmap",BitmapFactory.decodeStream(new URL(image).openStream()));
  </code></pre>
  
  <p>And when I use that nothing in the app loads at all, none of the text views get set. </p>
  
  <p>My third try was this:</p>
  
  <pre><code> //get beer data
              JSONObject o = new JSONObject(result);
              String name = getName(o);
              String image = getImage(o);
              String abv = getABV(o);
              String ibu = getIBU(o);
              String glass = getGlass(o);
              String beerBreweryName = getBreweryName(o);
              String beerBreweryStyle = getBreweryStyle(o);
              String beerDescription = getDescription(o);
  
              InputStream in = new java.net.URL(image).openStream();
              Bitmap bitmap = BitmapFactory.decodeStream(in);
  
  
  
              views.setTextViewText(R.id.beerTitle, name);
              views.setTextViewText(R.id.beerBreweryName, beerBreweryName);
              views.setTextViewText(R.id.beerStyleName, beerBreweryStyle);
              views.setImageViewBitmap(R.id.image, bitmap);
  </code></pre>
  
  <p>This gave the same result as the last attempt, it would not even set any text views....</p>
  
  <p>Just tried another attempt after one of the answers posted below:</p>
  
  <pre><code>RemoteViews views = new RemoteViews(c.getPackageName(), R.layout.widget_test);
  
              //get beer data
              JSONObject o = new JSONObject(result);
              String name = getName(o);
              String imageURL = getImage(o);
              String abv = getABV(o);
              String ibu = getIBU(o);
              String glass = getGlass(o);
              String beerBreweryName = getBreweryName(o);
              String beerBreweryStyle = getBreweryStyle(o);
              String beerDescription = getDescription(o);
  
              Log.d("widgetImage" , imageURL);
              views.setImageViewUri(R.id.image, Uri.parse(imageURL));
  
              views.setTextViewText(R.id.beerTitle, name);
              views.setTextViewText(R.id.beerBreweryName, beerBreweryName);
              views.setTextViewText(R.id.beerStyleName, beerBreweryStyle);
  
  
  
  
              mgr.updateAppWidget(appWidgetIds, views);
  </code></pre>
  
  <p>This attempt lets all the text views load, but no image ever shows up. </p>