本文整理汇总了Java中com.google.firebase.remoteconfig.FirebaseRemoteConfig类的典型用法代码示例。如果您正苦于以下问题:Java FirebaseRemoteConfig类的具体用法?Java FirebaseRemoteConfig怎么用?Java FirebaseRemoteConfig使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FirebaseRemoteConfig类属于com.google.firebase.remoteconfig包,在下文中一共展示了FirebaseRemoteConfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: pluginInitialize
import com.google.firebase.remoteconfig.FirebaseRemoteConfig; //导入依赖的package包/类
@Override
protected void pluginInitialize() {
Log.d(TAG, "Starting Firebase Remote Config plugin");
this.firebaseRemoteConfig = FirebaseRemoteConfig.getInstance();
String filename = preferences.getString("FirebaseRemoteConfigDefaults", "");
if (filename.isEmpty()) {
// always call setDefaults in order to avoid exception
// https://github.com/firebase/quickstart-android/issues/291
this.firebaseRemoteConfig.setDefaults(Collections.<String, Object>emptyMap());
} else {
Context ctx = cordova.getActivity().getApplicationContext();
int resourceId = ctx.getResources().getIdentifier(filename, "xml", ctx.getPackageName());
this.firebaseRemoteConfig.setDefaults(resourceId);
}
}
示例2: onCreate
import com.google.firebase.remoteconfig.FirebaseRemoteConfig; //导入依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Login checks
if (!CacheUtils.isLoggedIn(this) || !CacheUtils.isFireBaseSetup(this)) {
Intent intent = new Intent(this, OnBoardActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
finish();
return;
}
//Now check if app update is required
firebaseRemoteConfig = FirebaseRemoteConfig.getInstance();
firebaseRemoteConfig.setDefaults(R.xml.config);
testIfAppUpdateIsRequired();
}
示例3: getByteArray
import com.google.firebase.remoteconfig.FirebaseRemoteConfig; //导入依赖的package包/类
public void getByteArray(final CallbackContext callbackContext, final String key, final String namespace) {
mFirebase.cordova.getThreadPool().execute(new Runnable() {
public void run() {
try {
Log.i(TAG, "Getting byte array " + key);
byte[] bytes = namespace == null ? FirebaseRemoteConfig.getInstance().getByteArray(key)
: FirebaseRemoteConfig.getInstance().getByteArray(key, namespace);
JSONObject object = new JSONObject();
object.put("base64", Base64.encodeToString(bytes, Base64.DEFAULT));
object.put("array", new JSONArray(bytes));
callbackContext.success(object);
} catch (Exception e) {
Log.e(TAG, "Error getting byte array " + key, e);
callbackContext.error(e.getMessage());
}
}
});
}
示例4: getValue
import com.google.firebase.remoteconfig.FirebaseRemoteConfig; //导入依赖的package包/类
public void getValue(final CallbackContext callbackContext, final String key, final String namespace) {
mFirebase.cordova.getThreadPool().execute(new Runnable() {
public void run() {
try {
Log.i(TAG, "Getting value " + key);
FirebaseRemoteConfig remoteConfig = FirebaseRemoteConfig.getInstance();
FirebaseRemoteConfigValue value = (namespace == null)
? remoteConfig.getValue(key)
: remoteConfig.getValue(key, namespace);
callbackContext.success(value.asString());
} catch (Exception e) {
Log.e(TAG, "Error getting value " + key, e);
callbackContext.error(e.getMessage());
}
}
});
}
示例5: getInfo
import com.google.firebase.remoteconfig.FirebaseRemoteConfig; //导入依赖的package包/类
public void getInfo(final CallbackContext callbackContext) {
mFirebase.cordova.getThreadPool().execute(new Runnable() {
public void run() {
try {
Log.i(TAG, "Getting info");
FirebaseRemoteConfigInfo remoteConfigInfo = FirebaseRemoteConfig.getInstance().getInfo();
JSONObject settings = new JSONObject();
settings.put("developerModeEnabled", remoteConfigInfo.getConfigSettings().isDeveloperModeEnabled());
JSONObject info = new JSONObject();
info.put("configSettings", settings);
info.put("fetchTimeMillis", remoteConfigInfo.getFetchTimeMillis());
info.put("lastFetchStatus", remoteConfigInfo.getLastFetchStatus());
callbackContext.success(info);
} catch (Exception e) {
Log.e(TAG, "Error getting info", e);
callbackContext.error(e.getMessage());
}
}
});
}
示例6: setConfigSettings
import com.google.firebase.remoteconfig.FirebaseRemoteConfig; //导入依赖的package包/类
public void setConfigSettings(final CallbackContext callbackContext, final JSONObject config) {
mFirebase.cordova.getThreadPool().execute(new Runnable() {
public void run() {
try {
Log.i(TAG, "Setting config settings");
boolean devMode = config.getBoolean("developerModeEnabled");
FirebaseRemoteConfigSettings.Builder settings = new FirebaseRemoteConfigSettings.Builder()
.setDeveloperModeEnabled(devMode);
FirebaseRemoteConfig.getInstance().setConfigSettings(settings.build());
callbackContext.success();
} catch (Exception e) {
Log.e(TAG, "Error setting config settings", e);
callbackContext.error(e.getMessage());
}
}
});
}
示例7: setDefaults
import com.google.firebase.remoteconfig.FirebaseRemoteConfig; //导入依赖的package包/类
public void setDefaults(final CallbackContext callbackContext, final JSONObject defaults, final String namespace) {
mFirebase.cordova.getThreadPool().execute(new Runnable() {
public void run() {
try {
Log.i(TAG, "Setting defaults");
Map<String, Object> defaultsMap = defaultsToMap(defaults);
FirebaseRemoteConfig remoteConfig = FirebaseRemoteConfig.getInstance();
if (namespace == null) {
remoteConfig.setDefaults(defaultsMap);
} else {
remoteConfig.setDefaults(defaultsMap, namespace);
}
callbackContext.success();
} catch (Exception e) {
Log.e(TAG, "Error setting defaults", e);
callbackContext.error(e.getMessage());
}
}
});
}
示例8: fetch
import com.google.firebase.remoteconfig.FirebaseRemoteConfig; //导入依赖的package包/类
void fetch() {
FirebaseRemoteConfig config = FirebaseRemoteConfig.getInstance();
config.activateFetched();
config.fetch(urgentUpdateFlag ? 0 : cacheExpiration)
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.d("KiseFetcher", "onFailure: " + e.getMessage());
}
})
.addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void aVoid) {
Log.d("KiseFetcher", "onSuccess");
}
})
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
Log.d("KiseFetcher", "onComplete");
}
});
disableUrgentUpdateFlag();
}
示例9: onCreate
import com.google.firebase.remoteconfig.FirebaseRemoteConfig; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
buildNotification();
setStatusMessage(R.string.connecting);
mFirebaseRemoteConfig = FirebaseRemoteConfig.getInstance();
FirebaseRemoteConfigSettings configSettings = new FirebaseRemoteConfigSettings.Builder()
.setDeveloperModeEnabled(BuildConfig.DEBUG)
.build();
mFirebaseRemoteConfig.setConfigSettings(configSettings);
mFirebaseRemoteConfig.setDefaults(R.xml.remote_config_defaults);
mPrefs = getSharedPreferences(getString(R.string.prefs), MODE_PRIVATE);
String email = mPrefs.getString(getString(R.string.email), "");
String password = mPrefs.getString(getString(R.string.password), "");
authenticate(email, password);
}
示例10: RemoteConfig
import com.google.firebase.remoteconfig.FirebaseRemoteConfig; //导入依赖的package包/类
@SuppressWarnings("ConstantConditions") public RemoteConfig(boolean isDebug, final IAnalytics analytics) {
firebaseRemoteConfig = FirebaseRemoteConfig.getInstance();
FirebaseRemoteConfigSettings configSettings =
new FirebaseRemoteConfigSettings.Builder().setDeveloperModeEnabled(isDebug).build();
firebaseRemoteConfig.setConfigSettings(configSettings);
firebaseRemoteConfig.setDefaults(R.xml.remote_config_defaults);
firebaseRemoteConfig.fetch().continueWith((Continuation<Void, Void>) task -> {
if (task.isSuccessful()) {
Log.e(TAG, "then: Success");
firebaseRemoteConfig.activateFetched();
analytics.setUserProperty(EXPERIMENT_ABOUT_MENU,
getExperimentVariant(EXPERIMENT_ABOUT_MENU));
return null;
}
Log.e(TAG, "then: Failure");
throw task.getException();
});
}
示例11: fetchFirebase
import com.google.firebase.remoteconfig.FirebaseRemoteConfig; //导入依赖的package包/类
private void fetchFirebase() {
FirebaseRemoteConfig remoteConfig = FirebaseRemoteConfig.getInstance();
remoteConfig.setConfigSettings(
new FirebaseRemoteConfigSettings.Builder()
.setDeveloperModeEnabled(BuildConfig.DEBUG)
.build());
remoteConfig.fetch()
.addOnCompleteListener(this, task -> {
if (task.isSuccessful()) {
remoteConfig.activateFetched();
setup();
} else {
Snackbar snackbar = Snackbar.make(findViewById(android.R.id.content), "Da ist was schiefgelaufen.\nVersuche es noch einmal...", Snackbar.LENGTH_SHORT);
View snackbarView = snackbar.getView();
snackbarView.setBackgroundColor(ContextCompat.getColor(getApplicationContext(), theme().primaryColorDark));
snackbar.show();
}
});
}
示例12: onCreate
import com.google.firebase.remoteconfig.FirebaseRemoteConfig; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
setTheme(R.style.UCOmoveTheme);
super.onCreate(savedInstanceState);
mBinding = DataBindingUtil.setContentView(this, R.layout.activity_main);
mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
mFirebaseRemoteConfig = FirebaseRemoteConfig.getInstance();
mFusedLocationClient = LocationServices.getFusedLocationProviderClient(this);
setupView();
showHome();
checkLocationPermissionsIfNeeded();
setupGooglePlayRateIfNeeded();
}
示例13: refreshApiEndpoints
import com.google.firebase.remoteconfig.FirebaseRemoteConfig; //导入依赖的package包/类
private void refreshApiEndpoints() {
FirebaseRemoteConfig remoteConfig = FirebaseRemoteConfig.getInstance();
String apisString = remoteConfig.getString(FB_CONFIG_OSM_APIS);
if (apisString == null || apisString.isEmpty()) {
return;
}
String[] stringArray = apisString.replace("[", "").replace("]", "").split(",");
for (int i = 0; i < stringArray.length; i++) {
String apiHost = stringArray[i].replace("\"", "");
boolean enabled = remoteConfig.getBoolean(FB_CONFIG_OSM_API_ENABLED_PREFIX + i);
if (enabled) {
OsmApiEndpoint endpoint = new OsmApiEndpoint(apiHost);
initializeOsmService(endpoint);
osmOverpassApis.add(endpoint);
}
}
}
示例14: initialize
import com.google.firebase.remoteconfig.FirebaseRemoteConfig; //导入依赖的package包/类
public AbstractDownloadHelper initialize(Activity activity) {
mActivity = activity;
mFirebaseRemoteConfig = FirebaseRemoteConfig.getInstance();
mFirebaseRemoteConfig.fetch().addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
mFirebaseRemoteConfig.activateFetched();
AD_RATE = mFirebaseRemoteConfig.getLong("ad_rate");
}
});
/* ColorTvSdk.init(activity, getAppId());
ColorTvSdk.setRecordAudioEnabled(false);
ColorTvSdk.onCreate();
ColorTvSdk.registerAdListener(mListener);*/
return this;
}
示例15: fetch
import com.google.firebase.remoteconfig.FirebaseRemoteConfig; //导入依赖的package包/类
@Override
public void fetch() {
FirebaseRemoteConfig.getInstance().fetch().addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
fetched = true;
fetchedSuccesful = task.isSuccessful();
if (task.isSuccessful()) {
FirebaseRemoteConfig.getInstance().activateFetched();
if (onConfigurationFetchListener != null)
onConfigurationFetchListener.onFetchComplete();
} else {
if (onConfigurationFetchListener != null)
onConfigurationFetchListener.onFetchFailed();
}
}
});
}