在Class A中定义 :
private WeakReference mContext;
A(Context context){
mContext = new WeakReference(context);
}
为何不能拥有context的弱引用?
怎么不可以?你定义的不就是虚引用对象嘛,还有最好带上泛型参数WeakReference
可以用,使用方法是
mContext = new WeakReference<>(context);
mContext.get()得到context实列进行使用