Android Picasso Image does not load

后端 未结 16 1791
醉梦人生
醉梦人生 2020-12-10 04:02

There are two situations I load images, first, just directly from the internet, and second, load images that are downloaded in the device. And whenever I load, 8~9 out of 10

16条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-10 04:17

    If anything not works, it is because of the some problem with the servers that are hosting images, their url does not directly take you to the image, but in backend something else is working, it may open in chrome or other browser, but not for sure in picasso it will load, so you may try this code :

    final OkHttpClient client = new OkHttpClient.Builder()
            .protocols(Collections.singletonList(Protocol.HTTP_1_1))
            .build();
    
    final Picasso picasso = new Picasso.Builder(this)
            .downloader(new OkHttp3Downloader(client))
            .build();
    
    Picasso.setSingletonInstance(picasso);
    

    where the OkHttp3Downloader instance is supplied by this library. https://github.com/JakeWharton/picasso2-okhttp3-downloader

提交回复
热议问题