如何正确控制Firebase远程配置?值不变

时间:2019-04-30 22:25:37

标签: java android firebase fetch firebase-remote-config

我想让Startapp Ads刚显示时就显示。 所以我决定依赖调用的Firebase服务(远程配置)。 但这并没有给我我想要的结果。 这是我的代码:

    @Override
     protected void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
      remoteConfig.setConfigSettings(new 
     FirebaseRemoteConfigSettings.Builder()
    .setDeveloperModeEnabled(true)
    .build());

    HashMap<String, Object>defaults = new HashMap<>();
    defaults.put("startApp_Ads_required",false);
    defaults.put("startApp_Splash_required",false);
    remoteConfig.setDefaults(defaults);

    final Task<Void> fetch = remoteConfig.fetch(0);
    fetch.addOnSuccessListener(this, new OnSuccessListener<Void>() {
        @Override
        public void onSuccess(Void aVoid) {
            remoteConfig.fetchAndActivate();

            adsControl();

        }
    });

     setContentView(R.layout.activity_main);

     *
     *
     private void adsControl(){

     boolean startApp_Splash_required = 
          (boolean)remoteConfig.getBoolean("startApp_Splash_required");
     boolean startApp_Ads_required = 
          (boolean)remoteConfig.getBoolean("startApp_Ads_required");

     StartAppSDK.init(this, "201033969",startApp_Ads_required);

     if(!startApp_Splash_required) {
        StartAppAd.disableSplash();
     }
     }

0 个答案:

没有答案