本文整理汇总了Java中com.google.firebase.remoteconfig.FirebaseRemoteConfig.setDefaults方法的典型用法代码示例。如果您正苦于以下问题:Java FirebaseRemoteConfig.setDefaults方法的具体用法?Java FirebaseRemoteConfig.setDefaults怎么用?Java FirebaseRemoteConfig.setDefaults使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.firebase.remoteconfig.FirebaseRemoteConfig
的用法示例。
在下文中一共展示了FirebaseRemoteConfig.setDefaults方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fetchRemoteConfig
import com.google.firebase.remoteconfig.FirebaseRemoteConfig; //导入方法依赖的package包/类
private void fetchRemoteConfig() {
final FirebaseRemoteConfig firebaseRemoteConfig = FirebaseRemoteConfig.getInstance();
firebaseRemoteConfig.setDefaults(R.xml.remote_config_defaults);
firebaseRemoteConfig.fetch(3600) //1h expiration time
.addOnCompleteListener(this, new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) {
firebaseRemoteConfig.activateFetched();
}
}
});
}
示例2: newInstance
import com.google.firebase.remoteconfig.FirebaseRemoteConfig; //导入方法依赖的package包/类
static FirebaseConfig newInstance(Config.State state) {
FirebaseRemoteConfig firebase = FirebaseRemoteConfig.getInstance();
firebase.setConfigSettings(buildSettings());
firebase.setDefaults(R.xml.remote_config_defaults);
return new FirebaseConfig(firebase, state);
}
示例3: setupFirebase
import com.google.firebase.remoteconfig.FirebaseRemoteConfig; //导入方法依赖的package包/类
private void setupFirebase() {
final FirebaseRemoteConfig firebaseRemoteConfig = FirebaseRemoteConfig.getInstance();
FirebaseRemoteConfigSettings configSettings = new FirebaseRemoteConfigSettings.Builder()
.setDeveloperModeEnabled(BuildConfig.DEBUG)
.build();
firebaseRemoteConfig.setConfigSettings(configSettings);
firebaseRemoteConfig.setDefaults(R.xml.remote_config_defaults);
firebaseRemoteConfig.fetch(3600).addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful()) firebaseRemoteConfig.activateFetched();
}
});
}
示例4: newInstance
import com.google.firebase.remoteconfig.FirebaseRemoteConfig; //导入方法依赖的package包/类
public static FirebaseConfig newInstance() {
final FirebaseRemoteConfig firebaseRemoteConfig = FirebaseRemoteConfig.getInstance();
FirebaseRemoteConfigSettings configSettings = new FirebaseRemoteConfigSettings.Builder()
.setDeveloperModeEnabled(BuildConfig.DEBUG)
.build();
firebaseRemoteConfig.setConfigSettings(configSettings);
firebaseRemoteConfig.setDefaults(R.xml.remote_config_defaults);
return new FirebaseConfig(firebaseRemoteConfig);
}
示例5: doInBackground
import com.google.firebase.remoteconfig.FirebaseRemoteConfig; //导入方法依赖的package包/类
@Override
protected Void doInBackground(Void... voids) {
// Bug tracking
CrashlyticsCore core = new CrashlyticsCore.Builder().disabled(BuildConfig.DEBUG).build();
Fabric.with(LWQApplication.get(), new Crashlytics.Builder().core(core).build());
// ImageLoader Requires Disk Access to Initialize
LWQImageControllerHelper.get();
// Remote Config
FirebaseRemoteConfigSettings configSettings = new FirebaseRemoteConfigSettings.Builder()
.setDeveloperModeEnabled(BuildConfig.DEBUG)
.build();
FirebaseRemoteConfig firebaseRemoteConfig = FirebaseRemoteConfig.getInstance();
firebaseRemoteConfig.setConfigSettings(configSettings);
firebaseRemoteConfig.setDefaults(R.xml.remote_config_defaults);
// Firebase Analytics
FirebaseAnalytics firebaseAnalytics = FirebaseAnalytics.getInstance(LWQApplication.get());
firebaseAnalytics.setAnalyticsCollectionEnabled(!BuildConfig.DEBUG);
firebaseAnalytics.setMinimumSessionDuration(1000);
// AdMob
MobileAds.initialize(getApplicationContext(), getString(R.string.admob_app_id));
MobileAds.setAppMuted(true);
// Enable
setComponentsEnabled(!LWQPreferences.isFirstLaunch());
// Cache images if FTUETask completed
if (!LWQPreferences.isFirstLaunch()) {
cacheRemoteImageAssets();
}
return null;
}
示例6: firebaseRemoteConfig
import com.google.firebase.remoteconfig.FirebaseRemoteConfig; //导入方法依赖的package包/类
@Provides
@Singleton
static FirebaseRemoteConfig firebaseRemoteConfig(@RemoteConfigDefaults int resourceId) {
FirebaseRemoteConfig config = FirebaseRemoteConfig.getInstance();
config.setDefaults(resourceId);
config.fetch().addOnSuccessListener(result -> config.activateFetched());
return config;
}
示例7: fetchRemoteConfigs
import com.google.firebase.remoteconfig.FirebaseRemoteConfig; //导入方法依赖的package包/类
private void fetchRemoteConfigs() {
ServerConfigsHelper.removeAPIEndpoint(FavouriteJourneysActivity.this);
FirebaseRemoteConfig firebaseRemoteConfig = FirebaseRemoteConfig.getInstance();
FirebaseRemoteConfigSettings configSettings = new FirebaseRemoteConfigSettings.Builder()
.setDeveloperModeEnabled(BuildConfig.DEBUG)
.build();
firebaseRemoteConfig.setConfigSettings(configSettings);
firebaseRemoteConfig.setDefaults(R.xml.remote_config_defaults);
long cacheExpiration = 720; // 1/5 hour in seconds.
if (firebaseRemoteConfig.getInfo().getConfigSettings().isDeveloperModeEnabled()) {
Log.d("fetchRemoteConfigs: changing cache expiration");
cacheExpiration = 0;
}
firebaseRemoteConfig.fetch(cacheExpiration)
.addOnCompleteListener(this, task -> {
if (task.isSuccessful()) {
firebaseRemoteConfig.activateFetched();
} else {
// FirebaseCrash.report(new Exception("Firebase Remote Config FAILED in ADDONCOMPLETELISTENER"));
}
if (firebaseRemoteConfig.getBoolean(FIREBASE_IS_STRIKE_SET)) {
updateDashboard(firebaseRemoteConfig.getString(FIREBASE_STRIKE), ViewsUtils.COLORS.RED, false, false);
} else if (firebaseRemoteConfig.getBoolean(FIREBASE_IS_MAINTENANCE_SET)) {
updateDashboard(firebaseRemoteConfig.getString(FIREBASE_MAINTENANCE), ViewsUtils.COLORS.ORANGE, false, false);
} else if (firebaseRemoteConfig.getLong(FIREBASE_LATEST_VERSION) > BuildConfig.VERSION_CODE) {
updateDashboard(firebaseRemoteConfig.getString(FIREBASE_UPDATE_MESSAGE), ViewsUtils.COLORS.BLUE, true, false);
} else if (FirebaseRemoteConfig.getInstance().getBoolean(FIREBASE_IS_DISCOUNT_SET)) {
updateDashboard(FirebaseRemoteConfig.getInstance().getString(FIREBASE_DISCOUNT_MESSAGE), ViewsUtils.COLORS.ORANGE, false, true);
}
if (shouldDisplayDiscountMessage) {
btnIAP.setText(FirebaseRemoteConfig.getInstance().getString(FIREBASE_UPGRADE_BTN_HOME_MESSAGE).replace("\\n", System.getProperty("line.separator"))
+ " " + new String(Character.toChars(0x21AA)));
apply(btnIAP, VISIBLE);
}
})
.addOnFailureListener(this, e -> {
if (shouldDisplayDiscountMessage) {
apply(btnIAP, VISIBLE);
}
// FirebaseCrash.report(new Exception("Firebase Remote Config FAILED in ADDONFAILURELISTENER"));
});
}
示例8: onOptionsItemSelected
import com.google.firebase.remoteconfig.FirebaseRemoteConfig; //导入方法依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_share:
//Allow changing the share message via Firebase
FirebaseRemoteConfig firebaseRemoteConfig = FirebaseRemoteConfig.getInstance();
firebaseRemoteConfig.setDefaults(R.xml.remote_config_defaults);
String shareBody = firebaseRemoteConfig.getString(Constants.FIREBASE_CONFIG_SHARE_APP_MESSAGEREQUIRED + "_" + StringsManager.getCurrentLanguage());
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, StringsManager.getString("share_subject"));
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);
startActivity(Intent.createChooser(sharingIntent, StringsManager.getString("share_select")));
return true;
case R.id.action_language:
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(StringsManager.getString("change_language_title"));
String[] languages = new String[]{"Català", "Aranés", "Castellano", "English"};
builder.setItems(languages, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String newLang;
switch (which) {
case 0:
default:
newLang = "ca";
break;
case 1:
newLang = "oc";
break;
case 2:
newLang = "es";
break;
case 3:
newLang = "en";
break;
}
if (!newLang.equals(StringsManager.getCurrentLanguage())) {
StringsManager.setLanguage(newLang);
Intent intent = new Intent(MainActivity.this, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
finish();
}
dialog.dismiss();
}
});
builder.show();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
示例9: getUserPollingStation
import com.google.firebase.remoteconfig.FirebaseRemoteConfig; //导入方法依赖的package包/类
public static PollingStationResponse getUserPollingStation(String nif, Date birthDate, int zipCode) {
PollingStationResponse pollingStationResponse = new PollingStationResponse();
String keyDate = new SimpleDateFormat("yyyyMMdd", Locale.US).format(birthDate);
String keyZipCode = String.format(Locale.US, "%05d", zipCode);
String keyNif = nif.toUpperCase(Locale.US).substring(nif.length() - 6, nif.length());
String key = keyNif + keyDate + keyZipCode;
String firstSha256 = hash(bucleHash(key));
String secondSha256 = hash(firstSha256);
String dir = secondSha256.substring(0, 2);
String file = secondSha256.substring(2, 4);
FirebaseRemoteConfig firebaseRemoteConfig = FirebaseRemoteConfig.getInstance();
firebaseRemoteConfig.setDefaults(R.xml.remote_config_defaults);
String api = firebaseRemoteConfig.getString(Constants.FIREBASE_CONFIG_API_URL);
try {
URL url = new URL(api + dir + "/" + file + ".db");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setConnectTimeout(30000);
conn.setReadTimeout(30000);
BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
StringBuilder resultStringBuilder = new StringBuilder();
String str;
while ((str = in.readLine()) != null) {
if (resultStringBuilder.length() != 0) {
resultStringBuilder.append("\n");
}
resultStringBuilder.append(str);
}
in.close();
String[] lines = resultStringBuilder.toString().split("\n");
String result = null;
for (String line : lines) {
if (line.substring(0, 60).equals(secondSha256.substring(4))) {
result = decrypt(line.substring(60), firstSha256);
}
}
if (result != null) {
String[] info = result.split("#");
ColegiElectoral colegiElectoral = new ColegiElectoral();
colegiElectoral.setLocal(info[0]);
colegiElectoral.setAdresa(info[1]);
colegiElectoral.setMunicipi(info[2]);
colegiElectoral.setDistricte(info[3]);
colegiElectoral.setSeccio(info[4]);
colegiElectoral.setMesa(info[5]);
pollingStationResponse.setStatus("ok");
pollingStationResponse.setPollingStation(colegiElectoral);
} else {
pollingStationResponse.setStatus("not_found");
pollingStationResponse.setPollingStation(null);
}
} catch (Exception e) {
pollingStationResponse.setStatus("error");
pollingStationResponse.setPollingStation(null);
}
return pollingStationResponse;
}