Reputation: 901
Since Application is known for its global-variable usage. I was thinking maybe it's good to load Firebase remote config in onCreate() method in Application class and all variable will be stored as "public static" and with an initial value.
Just want to know if it is a good idea because I've tried to store remote-configs as private objects with classic getter/setter and that causes null-exceptions frequently.
Upvotes: 3
Views: 2735
Reputation: 317392
Don't use Application. If you have (or ever will have) a multi-process app, some Firebase features may have problems with that.
There is no guarantee that putting a call to fetch() early on in your app will make the values available as soon as they're needed. You should build your app taking into account that it may take some time to load Remote Config parameters. If you absolutely require them at launch, make a load screen and start the fetch there, progressing only when they're finished loading.
There are different strategies for using Remote Config, and they're outlined in this blog.
Upvotes: 7
Reputation: 672
What do you mean by Firebase remote-configs?
In my experiences, I usually use Application onCreate() to start Firebase services.
Then gather the Firebase token and listen to its changes. I use SharedPref to store my Firebase token.
That is my approach.
The cause of null-exception is depended on different context. So, it is better if you show your implementation.
Upvotes: 0