Here is my code where I used Picasso as well as glide library, but the image did not get displayed in the ImageView
. I even tried HTTP method, didn't work
String icon = pojo.getCurrent().getWeather().get(0).getIcon();
String iconUrl = "http://openweathermap.org/img/w/" + icon + ".png";
Log.v("AAA",iconUrl);
//Picasso.get().load(iconUrl).resize(20,20).centerCrop().into(weatherImage);
Glide.with(requireActivity().getApplicationContext()).load(iconUrl).into(weatherImage);
I also added the dependencies
this is the layout file
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/shape"
android:orientation="horizontal">
<Button
android:id="@+id/id_weather_refresh"
android:layout_width="30dp"
android:layout_height="40dp"
android:drawableEnd="@drawable/ic_baseline_refresh"
android:padding="5dp"
android:textColor="#FFFFFF" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:orientation="vertical">
<TextView
android:id="@+id/id_temperature"
android:layout_width="fill_parent"
android:layout_height="60dp"
android:fontFamily="casual"
android:gravity="center"
android:text="-:-/-:-"
android:textColor="#040404"
android:textSize="34sp"
android:textStyle="bold" />
<TextView
android:id="@+id/id_envType"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center|center_vertical"
android:text="---------"
android:textColor="#716F6F" />
</LinearLayout>
<androidx.cardview.widget.CardView
android:layout_width="110dp"
android:layout_height="110dp"
app:cardCornerRadius="20dp">
<ImageView
android:id="@+id/id_weatherImage"
android:layout_width="110dp"
android:layout_height="110dp"
android:src="@drawable/ic_launcher_background" />
</androidx.cardview.widget.CardView>
</LinearLayout>
I have posted an image of what's happening, actually it has to download the image from internet and display it there, but instead it's not displaying anything.
This is the URL of the image
The error message
2022-05-11 17:06:31.754 12117-12117/com.example.clothme I/Glide: Root cause (1 of 1)
java.io.IOException: Cleartext HTTP traffic to openweathermap.org not permitted
at com.android.okhttp.HttpHandler$CleartextURLFilter.checkURLPermitted(HttpHandler.java:127)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:462)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:131)
at com.bumptech.glide.load.data.HttpUrlFetcher.loadDataWithRedirects(HttpUrlFetcher.java:100)
at com.bumptech.glide.load.data.HttpUrlFetcher.loadData(HttpUrlFetcher.java:56)
at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.loadData(MultiModelLoader.java:100)
at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.startNextOrFail(MultiModelLoader.java:164)
at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.onLoadFailed(MultiModelLoader.java:154)
at com.bumptech.glide.load.data.HttpUrlFetcher.loadData(HttpUrlFetcher.java:62)
at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.loadData(MultiModelLoader.java:100)
at com.bumptech.glide.load.engine.SourceGenerator.startNextLoad(SourceGenerator.java:70)
at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:63)
at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:310)
at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:279)
at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)
at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:393)
2022-05-11 17:06:32.362 12117-16853/com.example.clothme I/example.clothm: Waiting for a blocking GC Instrumentation
2022-05-11 17:06:35.370 12117-16853/com.example.clothme I/example.clothm: Waiting for a blocking GC Instrumentation
2022-05-11 17:06:35.379 12117-16853/com.example.clothme I/example.clothm: WaitForGcToComplete blocked Instrumentation on ProfileSaver for 9.615ms