Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Firebase Workshop RemoteConfig 관련 코드 조각
//in SplashActivity.java
@Override
protected void onResume() {
super.onResume();
FirebaseRemoteConfig.getInstance().fetch(60)
.addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
//MessageListTheme is a simple static class to share the color values
//with other activities.
FirebaseRemoteConfig.getInstance().activateFetched();
MessageListTheme.MessageBackgroundColor =
Color.parseColor(
FirebaseRemoteConfig.getInstance().getString("message_background_color"));
MessageListTheme.MessageTextColor =
Color.parseColor(
FirebaseRemoteConfig.getInstance().getString("message_text_color"));
startActivity(new Intent(SplashActivity.this, MainActivity.class));
finish();
}
})
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Map<String, Object> defaultConfig = new HashMap<>();
defaultConfig.put("message_background_color", "#FF000000");
defaultConfig.put("message_text_color", "#FFFFFFFF");
FirebaseRemoteConfig.getInstance().setDefaults(defaultConfig);
MessageListTheme.MessageBackgroundColor =
Color.parseColor(
FirebaseRemoteConfig.getInstance().getString("message_background_color"));
MessageListTheme.MessageTextColor =
Color.parseColor(
FirebaseRemoteConfig.getInstance().getString("message_text_color"));
startActivity(new Intent(SplashActivity.this, MainActivity.class));
finish();
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment