Shorter method (recommended):
Replacing SomeClass.thisyour intention with help getApplicationContext()should do the trick.
The method I use (a bit more elongated and probably not the best of the two):
In each class do a private Context mContext;
Then in onCreate()each class do mContext = this;
Finally, replace SomeClass.thisin your intention with mContext.
source
share