0

I cannot load images to my app. I tried with vanilla Android Studio Java and with Picasso, nothing happens:

<ImageView
android:id="@+id/activity_main_icon"
android:layout_width="match_parent"
android:layout_height="308dp"/>
private ImageView icon;
icon = findViewById(R.id.activity_main_icon);

With

URL u = new URL("http://openweathermap.org/img/wn/" + i + ".png");                          
icon.setImageBitmap(BitmapFactory.decodeStream(u.openConnection().getInputStream()))

or

String iconUrl = "http://openweathermap.org/img/w/" + i + ".png";
Picasso.get().load(iconUrl).into(icon);

I checked the url it is ok.

It may be the declaration of the image in my activity, but I followed the documentation.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Jean T
  • 304
  • 1
  • 8
  • 1
    Does this answer your question? [How does one use glide to download an image into a bitmap?](https://stackoverflow.com/questions/27394016/how-does-one-use-glide-to-download-an-image-into-a-bitmap) – Anggrayudi H Sep 10 '20 at 19:00
  • What's the value of `i`? I am getting a 404 on browser when I tried https://openweathermap.org/img/wn/1.png (tried 0, 1, 2) as well. Or maybe I don't have access to it :) – Siddharth Kamaria Sep 12 '20 at 08:38
  • You should try to use https instead of http. It is just a shot, because could be an issue with the image, or your internet connection, your hardware, etc. – Rafa Sep 10 '20 at 18:14

0 Answers0