The Kount Android SDK provides several configuration options to customize its behavior for your application. This guide covers all available configuration methods, their parameters, and best practices.
Configures the SDK to use either the test or production environment.Parameters:
environment (int): The target environment
KountSDK.ENVIRONMENT_TEST - Test environment (default)
KountSDK.ENVIRONMENT_PRODUCTION - Production environment
Example:
// Test environmentKountSDK.INSTANCE.setEnvironment(KountSDK.ENVIRONMENT_TEST);// Production environmentKountSDK.INSTANCE.setEnvironment(KountSDK.ENVIRONMENT_PRODUCTION);
Environment Details:
Environment
Value
Description
Use Case
ENVIRONMENT_TEST
Test
Sends data to Kount’s test servers
Development and testing
ENVIRONMENT_PRODUCTION
Production
Sends data to Kount’s production servers
Live production apps
Always use ENVIRONMENT_TEST during development and testing. Switch to ENVIRONMENT_PRODUCTION only for production releases.
The order of configuration calls does not matter, but all configuration must be completed before calling collectForSession():
// Correct - all configuration before collectionKountSDK.INSTANCE.setMerchantId("999999");KountSDK.INSTANCE.setEnvironment(KountSDK.ENVIRONMENT_TEST);KountSDK.INSTANCE.setCollectAnalytics(true);KountSDK.INSTANCE.collectForSession(this, successCallback, failureCallback);// Also correct - different orderKountSDK.INSTANCE.setEnvironment(KountSDK.ENVIRONMENT_TEST);KountSDK.INSTANCE.setCollectAnalytics(true);KountSDK.INSTANCE.setMerchantId("999999");KountSDK.INSTANCE.collectForSession(this, successCallback, failureCallback);
Use BuildConfig to automatically switch configurations based on build type:
Java
Kotlin
public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Automatically configure based on build type KountSDK.INSTANCE.setMerchantId(getMerchantId()); KountSDK.INSTANCE.setEnvironment(getEnvironment()); KountSDK.INSTANCE.setCollectAnalytics(BuildConfig.DEBUG); } private String getMerchantId() { return BuildConfig.DEBUG ? "999999" : "123456"; } private int getEnvironment() { return BuildConfig.DEBUG ? KountSDK.ENVIRONMENT_TEST : KountSDK.ENVIRONMENT_PRODUCTION; }}
class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) // Automatically configure based on build type KountSDK.setMerchantId(getMerchantId()) KountSDK.setEnvironment(getEnvironment()) KountSDK.setCollectAnalytics(BuildConfig.DEBUG) } private fun getMerchantId(): String { return if (BuildConfig.DEBUG) "999999" else "123456" } private fun getEnvironment(): Int { return if (BuildConfig.DEBUG) { KountSDK.ENVIRONMENT_TEST } else { KountSDK.ENVIRONMENT_PRODUCTION } }}
public class MyApplication extends Application { @Override public void onCreate() { super.onCreate(); // Configure SDK once for the entire app KountSDK.INSTANCE.setMerchantId("999999"); KountSDK.INSTANCE.setEnvironment(KountSDK.ENVIRONMENT_TEST); KountSDK.INSTANCE.setCollectAnalytics(true); }}