1.单例,成员变量有Context(如果这个Context是Activity的话就会内存泄露了),因为instance是静态的,持有context的引用
public class Singleton{ public static Singleton instance; public Context context; public static Singleton getInstance(Context context){ if(instance == null){ instance = new Singleton(); } instance.context = context;//正确的是这里context.getApplicationContext(); return instance; } }