42

I registered a ContentProvider in AndroidManifest.xml, and the ContentProvider.onCreate() was called even before the Application.onCreate(). I don't understand this behavior, in my opinion, It's more natural that Application.onCreate() be called before any of the components in the application. Could someone tell me the timing of Application.onCreate() and other components' onCreate() gets called?

Dagang
  • 24,586
  • 26
  • 88
  • 133
  • Show your `AndroidManifest.xml`. `Application.onCreate()` is called per process, so this can happen if you app is starting multiple process. What Android version and device is this happening on? – Nikolay Elenkov Aug 03 '12 at 06:01

2 Answers2

22

According a Google's issue it's how this should work (although documentation is wrong).

There's another question that have a workarround that can help you.

Community
  • 1
  • 1
lujop
  • 13,504
  • 9
  • 62
  • 95
5

It is exactly how it should work.

Documentation of Application class was updated starting from Android 4.2 and it says that Application#onCreate()

Called when the application is starting, before any activity, service, or receiver objects (excluding content providers) have been created.

Volodymyr
  • 6,393
  • 4
  • 53
  • 84