示例#1
0
 // Fetches latest parameter values from the cloud at a custom interval.
 // If the method is called within an interval, cached data is returned.
 public void GetCloudSettingsFiveMins()
 {
     config = AGConnectConfig.getInstance();
     config.fetch(300).addOnSuccessListener(new HmsSuccessListener <ConfigValues>((ConfigValues configValues) =>
     {
         config.apply(configValues);
         TestTip.Inst.ShowText("activity success");
     }))
     .addOnFailureListener(new HmsFailureListener((Exception e) =>
     {
         TestTip.Inst.ShowText("activity failure " + e.toString());
     }));
     showAllValues();
 }
示例#2
0
        // apply the config value laste fetched
        public void GetCloudSettingsWorkNextTime()
        {
            config = AGConnectConfig.getInstance();
            ConfigValues configValues = config.loadLastFetched();

            config.apply(configValues);
            config.fetch().addOnSuccessListener(new HmsSuccessListener <ConfigValues>((ConfigValues o) =>
            {
                TestTip.Inst.ShowText("activity success");
            }))
            .addOnFailureListener(new HmsFailureListener((Exception e) =>
            {
                TestTip.Inst.ShowText("activity failure " + e.toString());
            }));
            showAllValues();
        }
示例#3
0
        // fetch cloud setting, add success listener and failure listener
        public void GetCloudSettings()
        {
            config = AGConnectConfig.getInstance();
            config.fetch().addOnSuccessListener(new HmsSuccessListener <ConfigValues>((ConfigValues configValues) =>
            {
                // Applies parameter values
                config.apply(configValues);
                TestTip.Inst.ShowText("activity success");
                // Checks whether the ConfigValues object contains a requested key.
                TestTip.Inst.ShowText($"configValues contains {configValues.containKey("CloudBool")}");
                // Returns the value of type for a key.
                TestTip.Inst.ShowText($"configValues as string {configValues.getValueAsString("CloudString")}");
                TestTip.Inst.ShowText($"configValues as byte first byte {configValues.getValueAsByteArray("CloudByte")[0]}");
                TestTip.Inst.ShowText($"configValues as long {configValues.getValueAsLong("CloudLong").longValue()}");
                TestTip.Inst.ShowText($"configValues as double {configValues.getValueAsDouble("CloudDouble").doubleValue()}");
                TestTip.Inst.ShowText($"configValues as bool {configValues.getValueAsBoolean("CloudBool").booleanValue()}");

                showAllValues();
            }))
            .addOnFailureListener(new HmsFailureListener((Exception e) =>
            {
                TestTip.Inst.ShowText("activity failure " + e.toString());
            }));
        }