[Android] Application#onCreate is Called Before Activity, Service, and Receiver Objects Are Created

Tadashi Shigeoka ·  Fri, July 19, 2013

In Android app development, Application#onCreate appears to be called before Activity, Service, and Receiver objects are created.

public void onCreate ()

Called when the application is starting, before any activity, service, or receiver objects (excluding content providers) have been created. Implementations should be as quick as possible (for example using lazy initialization of state) since the time spent in this function directly impacts the performance of starting the first activity, service, or receiver in a process. If you override this method, be sure to call super.onCreate().

[Source]: Application#onCreate() | Android Developers

For example, if you write Google Analytics tracking code in the Application#onCreate method, it will be tracked every time Service or Receiver objects are created.

This can cause abnormal values in active users and session counts, so caution is needed.

That’s all from the Gemba.