I have been trying to implement Volley
in my project. I am using google developers guide for understanding the concepts.
In the second lesson, setting up RequestQueue
as a singleton(Recommended practice) is taught. The following is a code snippet from that lesson.
public class MySingleton {
private static MySingleton mInstance;
private RequestQueue mRequestQueue;
private ImageLoader mImageLoader;
private static Context mCtx;
private MySingleton(Context context) {
mCtx = context;
mRequestQueue = getRequestQueue();
Now coming to my question, when I followed this code I'm getting lints (in Android Studio 2.2) as follows.
Do not place Android context classes in static fields (static reference to ApiRequestQueue which has field context pointing to Context); this is a memory leak (and also breaks Instant Run)
For the lines 2 and 5 in the above snippet.
What should I do? Should I suppress them or is there a way around?
Thanks.