简体   繁体   中英

Can not load GIF from GeoNames link with Glide

1 GeoNames

 Glide.with(this)
            .load("https://www.geonames.org/flags/x/ad.gif")
            .into(imageViewFlag_info);

2 Giphy

Glide.with(this)
        .load("https://media.giphy.com/media/98uBZTzlXMhkk/giphy.gif")
        .into(imageViewFlag_info);

1 and 2 are different

2nd example works with Giphy but Glide can't load image from GeoNames link.

Specify an appropriate User-Agent by using GlideUrl :

GlideUrl glideUrl = new GlideUrl("https://www.geonames.org/flags/x/ad.gif", new LazyHeaders.Builder()
        .addHeader("User-Agent", "Mozilla/5.0")
        .build());

Glide.with(this)
        .load(glideUrl)
        .into(imageViewFlag_info);

Try this tutorial to setup GlideApp: https://futurestud.io/tutorials/glide-getting-started Then write this line of code and it should work on your use case

GlideApp.with(imageView).asGif().load("URL").into(imageView);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM