This seems to be the solution when the page is redirected: http://blog.kosev.net/2011/01/follow-302-redirects-with.html
How to get image from an HTML page in Android
-
01-07-2022 - |
Question
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?
Solution 2
OTHER TIPS
I recommend you to look at this library: http://jsoup.org/
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow