本文整理匯總了Java中com.google.firebase.remoteconfig.FirebaseRemoteConfig.getString方法的典型用法代碼示例。如果您正苦於以下問題:Java FirebaseRemoteConfig.getString方法的具體用法?Java FirebaseRemoteConfig.getString怎麽用?Java FirebaseRemoteConfig.getString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.firebase.remoteconfig.FirebaseRemoteConfig
的用法示例。
在下文中一共展示了FirebaseRemoteConfig.getString方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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);
}
}
}
示例2: convertFirebaseDataToJsonArray
import com.google.firebase.remoteconfig.FirebaseRemoteConfig; //導入方法依賴的package包/類
/**
*
* @param remoteConfig
* @param testList
* @return JSONArray of experiment data
*/
public static JSONArray convertFirebaseDataToJsonArray(FirebaseRemoteConfig remoteConfig, List<String> testList){
JSONArray array = new JSONArray();
Iterator iterator = testList.iterator();
while (iterator.hasNext()) {
JSONObject object = new JSONObject();
String testName = (String) iterator.next();
try {
object.put(NAME, testName);
String testValue = remoteConfig.getString(testName);
if (TextUtils.isEmpty(testValue)) {
object.put(VARIANT, -1);
} else if (TextUtils.isDigitsOnly(testValue)) {
object.put(VARIANT, testValue);
} else {
JSONObject meta = new JSONObject();
object.put(VARIANT, -1);
meta.put(VAL, testValue);
object.put(METADATA, meta.toString());
}
} catch (JSONException e) {
}
array.put(object);
}
return array;
}
示例3: updateApiKeys
import com.google.firebase.remoteconfig.FirebaseRemoteConfig; //導入方法依賴的package包/類
public static void updateApiKeys(FirebaseRemoteConfig config, SharedPreferences prefs) {
String cacheBust = config.getString(APIV3_CACHE_BUST);
prefs.edit()
.putString(APIV3_KEY, config.getString(APIV3_KEY))
.putString(APIV3_CACHE_BUST, cacheBust != null ? cacheBust : "")
.apply();
}
示例4: 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);
}
}
示例5: 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;
}
示例6: sendPush
import com.google.firebase.remoteconfig.FirebaseRemoteConfig; //導入方法依賴的package包/類
@Deprecated
private void sendPush(FirebaseRemoteConfig firebaseRemoteConfig, String message, String accountId, String regId, boolean isIOS) {
String url = firebaseRemoteConfig.getString("server_push_url");
String key = firebaseRemoteConfig.getString("server_push_key");
KLog.v(TAG, url + "\n" + key);
JSONObject object = new JSONObject();
JSONObject dataObj = new JSONObject();
JSONObject notificationObj = new JSONObject();
try {
dataObj.put(KeyData.MESSAGE, message);
dataObj.put(KeyData.FROM_USER_HEAD_PIC, KomicaAccountManager.getInstance().getMyAccount().getHeaderPic());
dataObj.put(KeyData.FROM_USER_NAME, KomicaAccountManager.getInstance().getMyAccount().getUsername());
dataObj.put(KeyData.FROM_USER_ID, KomicaAccountManager.getInstance().getMyAccount().getFbId());
dataObj.put(KeyData.TO_USER_ID, accountId);
// for iOS device
dataObj.put(KeyData.CONTENT_AVAILABLE, true);
object.put(KeyData.TO, regId);
object.put(KeyData.PRIORITY, Priority.HIGH);
object.put(KeyData.DATA, dataObj);
if (isIOS) {
notificationObj.put(KeyNotification.NOTIFICATION_BODY, message);
notificationObj.put(KeyNotification.NOTIFICATION_TITLE, KomicaAccountManager.getInstance().getMyAccount().getUsername());
notificationObj.put(KeyNotification.NOTIFICATION_SOUND, "default");
notificationObj.put(KeyNotification.NOTIFICATION_BADGE, "1");
// notificationObj.put(KeyNotification.NOTIFICATION_ICON, KomicaAccountManager.getInstance().getMyAccount().getAvatarImgUrl());
object.put(KeyNotification.NOTIFICATION, notificationObj);
}
} catch (JSONException e) {
e.printStackTrace();
}
KLog.v(TAG, object.toString());
if ((url == null || url.isEmpty()) && (key == null || key.isEmpty())) {
return;
}
AndroidNetworking.post(url)
.addHeaders("Authorization", key)
.addHeaders("Content-Type", OkHttpClientConnect.CONTENT_TYPE_JSON)
.addBodyParameter(object).build().getAsString(new StringRequestListener() {
@Override
public void onResponse(String response) {
KLog.v(TAG, response);
}
@Override
public void onError(ANError anError) {
KLog.v(TAG, "onFailure: " + anError);
}
});
}