-1

How to display images from this HREF in android.

http://www.sandesh.com/article.aspx?newsid=3048433'>http://www.sandesh.com/uploadimages/national/News2_20150302194317737.jpg' />

2 Answers2

1

I think this might be what you are wanting. Check out this question for original code: How to load an ImageView by URL in Android?

// show The Image
new DownloadImageTask((ImageView) findViewById(R.id.imageView1))
        .execute("http://java.sogeti.nl/JavaBlog/wp-
content/uploads/2009/04/android_icon_256.png");
}

public void onClick(View v) {
startActivity(new Intent(this, IndexActivity.class));
finish();

} 

private class DownloadImageTask extends AsyncTask<String, Void, Bitmap> {
ImageView bmImage;

public DownloadImageTask(ImageView bmImage) {
    this.bmImage = bmImage;
}

protected Bitmap doInBackground(String... urls) {
    String urldisplay = urls[0];
    Bitmap mIcon11 = null;
    try {
        InputStream in = new java.net.URL(urldisplay).openStream();
        mIcon11 = BitmapFactory.decodeStream(in);
    } catch (Exception e) {
        Log.e("Error", e.getMessage());
        e.printStackTrace();
    }
    return mIcon11;
}

protected void onPostExecute(Bitmap result) {
    bmImage.setImageBitmap(result);
}
}

And set the correct user permissoins in your Android Manifest file.

<uses-permission android:name="android.permission.INTERNET" />
Community
  • 1
  • 1
0

You can use Picasso Library

 Picasso.with(context)
            .load("http://www.sandesh.com/uploadimages/national/News2_20150302194317737.jpg")
            .placeholder(R.drawable.your_place_holder_drawable) //optional
            .error(R.drawable.your_errorRes_drawable)//optional
            .into(yourImageViewInstane);

In build.gradle file

dependencies {
    ...
    compile 'com.squareup.picasso:picasso:2.4.0'
}
Konrad Krakowiak
  • 12,285
  • 11
  • 58
  • 45