I've come across this android code below. Is there ever a use case of creating a static weakreference object in a service to get its reference? I know that static variables are not eligible for Garbage collection. In general, Does creating a weak reference of any static variable change its gc properties?
for example:
private static WeakReference<MyService> mService;
public static MyService getInstance(){
if(mService != null){
return mService.get();
}
return null;
}
And in my onCreate
public void onCreate(){
super.onCreate();
mService = new WeakReference<MyService>(this);
}