In some of my applications, I use several singleton objects as "managers". I create them in Application.onCreate and pass them the ApplicationContext , which I store in WeakReference .
Some of the "manager" methods start a background task after a call from Activity , so I pass the Activity context method to the method and save the WeakReference in it (and use what's inside AsyncTask ). This link remains until the next time the Activity calls a method that goes into the background when the WeakReference set to a new Activity context .
My question is, should the ApplicationContext be stored in WeakReference , and are there any problems with maintaining the Activity context ?
android android-context android-asynctask android-memory
Eliezer Oct 23 '13 at 1:23 2013-10-23 01:23
source share