2

Currently I am using Glide to show images. I have created the custom header(Authorization) for it

public class HeadersClass {



public static GlideUrl getUrlWithHeaders(String url){
    return new GlideUrl(url, new LazyHeaders.Builder()
            .addHeader("token", "lkajsdlkjasldjasldjaslkdjaslkdj")
            .build());
}

}

And using in Glide like this

Glide.with(getActivity())
           // .load(baseUrlForImage + urlOfImage)
            .load(HeadersClass.getUrlWithHeaders(baseUrlForImage + urlOfImage))
            .into(imageView);

And it's working fine but now the issue is the image URL are coming with HTTPS (in starting I was using http only).

With HTTPS now its not showing the image.

Is there any way for it and can I use some other lib for it?

  • any certification error are you getting with https ? if yes, visit https://stackoverflow.com/questions/41114569/glide-javax-net-ssl-sslhandshakeexception-java-security-cert-certpathvalidato/41114813#41114813 – hemen Aug 23 '18 at 05:45
  • i just copied my certificates in assets folder. and not getting any error. – Abhishek Punia Aug 23 '18 at 07:18
  • error is . : - Volley: Image Load Error: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found. – Abhishek Punia Sep 06 '18 at 09:48

2 Answers2

2

First you can declare header layout and find image view id and declare activity/fragment

            ImageView imageview=findViewById(R.id.imageview);

            ViewGroup header = (ViewGroup)inflaterHeader.inflate(R.layout.task_header, listView, false);
            listView.addHeaderView(header);

                 Picasso.get().
                    load(Url).
                    into(imageview);
Anand Gaur
  • 225
  • 2
  • 10
0
 GlideUrl glideUrl = new GlideUrl(**YOUR URL** new LazyHeaders.Builder()
                    .addHeader("Authorization", **YOUR TOKEN HERE**)
                    .build());
            Glide.with(context)
                    .load(glideUrl)
                    .apply(new RequestOptions()
                            .diskCacheStrategy(DiskCacheStrategy.NONE)
                            .skipMemoryCache(false)
                            .error(R.drawable.ic_no_pictures **REPLACE THIS WITH UR DRAWABLE**)
                            .dontAnimate()
                            .dontTransform())
                    .into(**IMAGEVIEW**);