0

Any Body know when Contentprovider will be loaded and onCreate() method is called .

I have a scenario where i do some checks and would like to exit the application .

My doubt is will the UI i mean activity instance available when onCreate() of provider is called .

i have googled it but no much data

Shaik Khader
  • 397
  • 4
  • 19
  • Take a look to [this answer](http://stackoverflow.com/questions/2033914/quitting-an-application-is-that-frowned-upon/2034238#2034238). – Nahuel Barrios Apr 16 '13 at 12:19

1 Answers1

1

As far as I understood you're question is regarding the time the ContentProvider.onCreate() and the Activity.onCreate() is called.

Probably the best option is just make a very simple test putting a line of Log.d(TAG, "onCreate activity"); and Log.d(TAG, "onCreate provider"); on both see which one get's triggered first.

But remember to keep the ContentProvider code short, as from the docs:

It must not perform lengthy operations, or application startup will be delayed.

Budius
  • 39,391
  • 16
  • 102
  • 144
  • I verified about time , contentprovider oncreate() is called first I was checking is there any way cancel launch of activity checking the condition in oncreate of contentprovider - – Shaik Khader Apr 16 '13 at 13:00
  • The ContentProvider and the Activity are independent of each other, some people will suggest using `static` stuff but IMO that's bad design. You probably want to do those checks during the Activity.onCreate(). Also, an app that opens and immediately closes is usually seen as bad or buggy by users. You probably want to put a dialog or something telling the user why the app will close. – Budius Apr 16 '13 at 13:06
  • thank you @Budius i too had a similar thought , i was just checking if there is any other solution . I will use your suggestion – Shaik Khader Apr 16 '13 at 13:12