问题
Here is a similar question but I think it is not identical
And I read Setting up request queue tutorial here
In this page they write the following code
public class MySingleton {
private static Context mCtx;
And I wrote same code in my project
public class VolleySingleton {
private static Context mContext;
Android studio say “Do not place Android context classes in static fields; this is a memory leak”.
What does it mean? And why dos the official android developer website use such kind of code?
回答1:
try this? `
class VolleySingleton {
@SuppressLint("StaticFieldLeak")
private static Context mContext;
}`
来源:https://stackoverflow.com/questions/48127346/android-studio-say-static-field-will-leak-contexts