[Android] Application#onCreate は Activity, Service, Receiver オブジェクトが生成される前に呼び出される

Fri, July 19, 2013 - 1 min read

Android アプリ開発にて、Application#onCreate は Activity, Service, Receiver オブジェクトが生成される前に呼び出されるみたいです。

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().

[引用元]:Application#onCreate() | Android Developers

例えば、Application#onCreate メソッド内に Google Analytics のアクセス解析処理を書いてたりすると、Service や Receiver オブジェクトが生成される度にトラッキングされてしまいます。