1

In the sample app fetch method is called in onCreate(). Is it really a good place to do this? The application can be used (moves from foreground to background and vice-versa, opens new activities and going back to main activity) for weeks and onCreate() from the main Activity won't be called again. I don't think it is good solution where my app won't update my configs for such a long time.

Update: It is very bad idea to fetch config values only in onCreate() method, some kind of check should be done in onStart(). Here is also some useful information: https://firebase.googleblog.com/2017/01/firebase-remote-config-loading.html

Grimthorr
  • 6,856
  • 5
  • 41
  • 53
AppiDevo
  • 3,195
  • 3
  • 33
  • 51
  • You should do whatever suits your app. onCreate is convenient for showing a quick demo, but if it doesn't work for you, there's no obligation to use it. – Doug Stevenson May 19 '17 at 16:20
  • Android sample apps can be very misleading, especially for new developers. It would have taken only few more minutes to add some logic in onStart() method with checking getFetchTimeMillis () value to trigger fetch(). – AppiDevo May 19 '17 at 16:37
  • @DougStevenson I have to admit I tried to implement fetch() call in onStart() method and it's not so easy as I thought earlier. Maybe you can help me? http://stackoverflow.com/questions/44091088/how-to-implement-fetch-from-firebase-remote-config-in-onstart-method – AppiDevo May 20 '17 at 21:47

1 Answers1

0

The link you shared shows example for demo purpose. Ideally you should do initialization in onCreate() and call for data in onStart() when onResume() gets called, the activity is visible and user can interact with your app. As said by @Doug Stevenson in comment that there is no obligation, but you should follow what is given in docs for best practice.

Rahul Ahuja
  • 812
  • 10
  • 24