Skip to content

Instantly share code, notes, and snippets.

@harshabhadra
Created October 13, 2019 14:35
Show Gist options
  • Save harshabhadra/17cc39d63ba2992c6d141ec1782f5cea to your computer and use it in GitHub Desktop.
Save harshabhadra/17cc39d63ba2992c6d141ec1782f5cea to your computer and use it in GitHub Desktop.
/**
* Fetch a welcome message from the Remote Config service, and then activate it.
*/
private void fetchWelcome() {
mWelcomeTextView.setText(mFirebaseRemoteConfig.getString(LOADING_PHRASE_CONFIG_KEY));
// [START fetch_config_with_callback]
mFirebaseRemoteConfig.fetchAndActivate()
.addOnCompleteListener(this, new OnCompleteListener<Boolean>() {
@Override
public void onComplete(@NonNull Task<Boolean> task) {
if (task.isSuccessful()) {
boolean updated = task.getResult();
Log.e(TAG, "Config params updated: " + updated);
} else {
Toast.makeText(MainActivity.this, "Fetch failed",
Toast.LENGTH_SHORT).show();
}
displayWelcomeMessage();
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment