Why does ContentProvider.onCreate() get called before Application.onCreate()?

前端 未结 2 728

I registered a ContentProvider in AndroidManifest.xml, and the ContentProvider.onCreate() was called even before the Application.onCreate(). I don\'t understand this behavio

相关标签:
2条回答
  • 2020-12-09 08:23

    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.

    0 讨论(0)
  • 2020-12-09 08:26

    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.

    0 讨论(0)
提交回复
热议问题