In some cases I can see that Activity.onCreate is called before the Appication object gets created (before Application.onCreate is called). Is that ever possible?
May be you forgot to add your application class in manifest file.
Place your application class in AndroidManifest.xml class under <application> tag.
i.e.,
<application
android:name=".{YourApplicationClassName}"
...
...
In some cases I can see that Activity.onCreate is called before the Appication object gets created (before Application.onCreate is called).
This is not what Android document says about the Application class. As per the official android documents,
The Application class, or your subclass of the Application class, is instantiated before any other class when the process for your application/package is created.
Also below is specific explanation of onCreate() of an Application class
Called when the application is starting, before any activity, service, or receiver objects (excluding content providers) have been created.
Hence the onCreate() of Application has to be invoked 1st and then onCreate() of Activity class
So the scenario you have mentioned is not possible as per the flow of instantiation of Application class and Activity class
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With