Setup Remote Configurations
GameAnalytics' Remote Configurations feature offers the ability to set up and tune values in your game's dashboard. These values can be changed at any time without needing to release a new version of the game.
The remote configs are a custom set of key-pair values. Set them up in the GameAnalytics dashboard.
Check Remote Config Updates in Android
To receive a callback when remote configs are updated, implement IRemoteConfigsListener:
public class MainActivity extends Activity implements IRemoteConfigsListener
{
public void onRemoteConfigsUpdated()
{
// add your code here
}
protected void onCreate(Bundle savedInstanceState)
{
GameAnalytics.addRemoteConfigsListener(this);
}
}
Manual Check for Remote Config Updates
To manually check if Remote Configs are ready (populated with values from the server):
if(GameAnalytics.isRemoteConfigsReady())
{
// the remote configs is ready, add your code here
}
The isRemoteConfigsReady function will return false if the configs haven't been populated by the server yet.
Retrieve Remote Config Values
Once Remote Configs are ready, retrieve values using the following methods:
// Without custom default value (using normal default value)
String value = GameAnalytics.getRemoteConfigsValueAsString("key");
// With custom default value
String valueWithCustomDefaultValue = GameAnalytics.getRemoteConfigsValueAsString("key", "myDefaultValue");
If the specified key is not found in the Remote Configs it will return the default value of either "normal" or "custom" value.
For more information on Remote Configs go here.