The reason for keeping a WeakReference
to the activity's context is so that you won't keep a reference to an Activity
that has been or otherwise should be destroyed already. No such issue exists for the Application
. A WeakReference
is unnecessary in that case.
It's hard to comment on your use of the activity's context since you haven't detailed what you're using it for exactly. It sounds a little suspicious that you're swapping out the context for different activities. If you really need a specific activity's context, this might be ok, but if you simply want a valid Context
to use with an AsyncTask
then I'd consider rethinking your approach. It'll probably work, but it's a bit hacky. There are other options that may be more appropriate depending on your needs: IntentService
and Loaders
are options to consider.