上一篇實現了https的雙向認證,但是發現使用Glide加載圖片的時候加載不出來,彆着急Glide早就爲我們提供好了方法了
首先呢在我們的buid裏面添加依賴
// Gilde compile 'com.squareup.okhttp3:okhttp:3.3.1' compile 'com.github.bumptech.glide:glide:3.7.0' /*提供的Module*/ compile 'com.github.bumptech.glide:okhttp3-integration:1.4.0@aar'
然後呢直接在我們初始化的地方調用
Glide.get(getApplicationContext()).register(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(client));
就ok了 client 就是上篇配置的Okhttp的client。配置好了之後就可以像原來一樣使用Glide加載圖片了