Do I have to be sure that if any of my application component is running (onCreate for Activity / Service, onReceived for BroadcastReceiver, etc.), then my application instance of the Application class already exists?
I have a static instance field in my application class
public class MyApplication extends Application {
private static MyApplication instance;
@Override
public void onCreate() {
instance = this;
super.onCreate();
}
public MyApplication getInstance(){
return instance;
}
Of course, this class is registered in the manifest. I wonder if using a static instance field is safe and always returns me the correct value. I have not used content providers before, but will it work with content providers?
source
share