You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Firebase Remote Config:如何获取所有String类型配置映射

获取所有String类型的Firebase Remote Config配置

既然你已经确认所有Remote Config配置值都是String类型,可以通过遍历getAll()返回的Map,调用FirebaseRemoteConfigValue的asString()方法提取字符串值,最终得到一个只包含String类型值的Map:

// 获取所有配置项
Map<String, FirebaseRemoteConfigValue> allRemoteConfigs = firebaseRemoteConfig.getAll();
// 用于存储转换后的String类型配置
Map<String, String> stringOnlyConfigs = new HashMap<>();

// 遍历并转换每个配置值
for (Map.Entry<String, FirebaseRemoteConfigValue> entry : allRemoteConfigs.entrySet()) {
    stringOnlyConfigs.put(entry.getKey(), entry.getValue().asString());
}

说明

  • asString()是FirebaseRemoteConfigValue接口提供的方法,专门用于将配置值转换为String类型。
  • 由于你已确保所有配置都是String类型,无需处理类型不匹配的异常(若存在非String类型配置,调用该方法会抛出IllegalStateException)。

内容的提问来源于stack exchange,提问作者Bitwise DEVS

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.20 09:51:28