The rule is never to hold a strong reference to a Context
beyond its normal lifetime. Android manages the Application
instance when your app is in use--there will always be one and only one for as long as Android keeps your app running. In short, the Application
context is the only one you can hold a reference to without worrying it will leak.
However, I think it's better to make the assignment in onCreate()
instead of in the public constructor. With few exceptions, for components managed by Android, onCreate()
should be the place you start running your own code.
@Override
public void onCreate() {
super.onCreate();
appContext = this;
}