Home > Software design >  Android Picasso how can I load image
Android Picasso how can I load image

Time:01-30

add in build.gradle library picasso add permission in Manifest file add ImageView to layout in MainActivity

  @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ImageView imageView = (ImageView) findViewById(R.id.imageView);
        String urlPath = "http://217.175.38.5:53389/photo/employee/262421?lastmod=1649263637";

        Glide
                .with(this)
                .load(urlPath)
                .into(imageView);

       Picasso
               .get()
               .load(urlPath)
               .into(imageView);

    }

I decided to try Glide, but it doesn't work too

CodePudding user response:

Because you must to load url with https or in manifest add this line

<?xml version="1.0" encoding="utf-8"?>
<manifest ...>
    <uses-permission android:name="android.permission.INTERNET" />
    <application
        ...
        android:usesCleartextTraffic="true"
        ...>
        ...
    </application>
</manifest>
  • Related