0

app is running in android older version and image showing perfectly but when its running in newer android version it looks blank in the imageview section. I have used Picasso.

String image_url = "http://***.com/uploads/user_photo/" + imagelist.get(position).getUser_photo();

    Picasso.with(context)
          .load(image_url )
          .into(holder.imgView);
Sandeep Malik
  • 1,972
  • 1
  • 8
  • 17
Taps
  • 27
  • 6
  • use https see https://stackoverflow.com/questions/45940861/android-8-cleartext-http-traffic-not-permitted – Lokesh Aug 20 '19 at 11:16
  • What is the `old` and `new` android version? – salmanwahed Aug 20 '19 at 11:16
  • mean android old version 4.4 (kitkat) and new version 9.0 (Pie) its works fine in kitkat but image is not uploaded in Pie – Taps Aug 20 '19 at 11:28
  • I have added res/xml/network_security_config.xml and also made domain-config cleartextTrafficPermitted="true" – Taps Aug 20 '19 at 11:32

3 Answers3

1

I suppose you mean it doesn't work on Android 9+ but works correctly on Android <= 8. That's probably the case since the image url you're trying to load uses http. Android 9+ blocks http by default and only accepts https urls.

Check this answer for details on how to enable http on Android 9+ for your application. How to allow all Network connection types HTTP and HTTPS in Android (9) Pie?

Keep in mind that it's fine when testing but you shouldn't enable http on a production app, they disabled it for a reason.

Hbibna
  • 568
  • 7
  • 11
0

Use Picasso.get().load("image_url").into(holder.imgView);

Gautham Nadar
  • 45
  • 2
  • 6
  • That means your Picasso library is outdated, updating it could break the project depending on other dependencies – cutiko Aug 20 '19 at 11:26
  • updated Picasso lib and used Picasso.get().load("image_url").into(holder.imgView); still same issues – Taps Aug 20 '19 at 11:42
0

Try this

Picasso.with(context)  // Activity context
       .load("https:URL") // Set URL
       .resize(100,100) // you also Resize the image
       .placeholder(getResources().getDrawable(R.drawable.waterMark)) // Default Image
       .error(getResources().getDrawable(R.drawable.errorImg)) // if errors occurs
       .into(holder.heroesImage); // Your Imageview

And Make sure your url is HTTPS

Navin Kumar
  • 3,393
  • 3
  • 21
  • 46