我正在使用Glide库,还使用Volley库执行一些HTTP请求。当我同时使用这两个库时,会收到以下消息:
W / OkHttpClient:与http:///的连接已泄漏。您是否忘了关闭响应主体?
是否有必要担心,或者一个库在关闭之前看到另一个库的连接仍处于打开状态,并且在某个时候它会关闭?
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_activity);
File cacheDir = new File(this.getCacheDir(), "Volley");
queue = new RequestQueue(new DiskBasedCache(cacheDir), new BasicNetwork(new
HurlStack()), 4);
queue.start();
}
public void start(){
String URL ="....."
Glide.with(this)
.load(url+"image.png").listener(new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
return false;
}
@Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
return false;
}
})
.into((ImageView) findViewById(R.id.imageView));
StringRequest stringRequest = new StringRequest(Request.Method.GET, url,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.d("VolleyError", error.toString());
}
});
queue.add(stringRequest);
}