Ich mache ein Demo-Projekt, um die Farbe eines einfachen TextView mit Firebase Remote Config zu ändern. Aber die Funktion mRemoteConfig.fetch (cacheExpiration) .addOnCompleteListener ... wird überhaupt nicht ausgelöst. Die Textfarbe ändert sich nicht.Firebase remote config fetch() löst überhaupt nicht aus
Hier ist mein Code:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
text = (TextView) findViewById(R.id.text);
initRemoteConfig();
}
private void initRemoteConfig() {
mRemoteConfig = FirebaseRemoteConfig.getInstance();
HashMap<String, Object> defaults = new HashMap<>();
defaults.put("color_primary", getString(R.string.color_primary));
mRemoteConfig.setDefaults(defaults);
FirebaseRemoteConfigSettings remoteConfigSettings = new FirebaseRemoteConfigSettings.Builder()
.setDeveloperModeEnabled(true)
.build();
mRemoteConfig.setConfigSettings(remoteConfigSettings);
fetchRemoteConfigValues();
}
private void fetchRemoteConfigValues() {
long cacheExpiration = 3600;
//expire the cache immediately for development mode.
if (mRemoteConfig.getInfo().getConfigSettings().isDeveloperModeEnabled()) {
cacheExpiration = 0;
}
mRemoteConfig.fetch(cacheExpiration)
.addOnCompleteListener(this, new OnCompleteListener<Void>() {
@Override
public void onComplete(Task<Void> task) {
if (task.isSuccessful()) {
// task successful. Activate the fetched data
mRemoteConfig.activateFetched();
setupView();
} else {
//task failed
}
}
});
}
private void setupView() {
setTextColor();
}
private void setTextColor() {
boolean isPromoOn = true;
int color = isPromoOn ? Color.parseColor(mRemoteConfig.getString("color_primary")) :
ContextCompat.getColor(this, R.color.color_primary);
text.setTextColor(color);
}
bin ich etwas fehlt? Vielen Dank für Ihre Hilfe :)