I use the following code do get an image from a regular image url:
try
{
url = new URL("http://example.com/test.jpg");
final Bitmap bmp = BitmapFactory.decodeStream(url.openConnection()
.getInputStream());
final ImageView imageView = (ImageView) findViewById(R.id.imageView2);
MainActivity.this.runOnUiThread(new Runnable()
{
@Override
public void run()
{
imageView.setImageBitmap(bmp);
}
});
}
catch (Exception e)
{
e.printStackTrace();
}
However, I want to download images that are displayed by html or php pages.
url = new URL("http://example.com/showimage.php");
If I use this, I get the following message:
SkImageDecoder::Factory returned null
How should I modify my code?
This seems to be the solution when the page is redirected: http://blog.kosev.net/2011/01/follow-302-redirects-with.html