SDK Initialization
To run the Real-time CDP SDK, you must initialize the SDK with configuration.
Run the following method at the time of app launch. This method stores user’s device details and customer UUID, which are required to be passed in the subsequent API calls.
Copy
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
context = this;
TargetOneSDKContext targetOneSDKContext = new TargetOneSDKContext();
targetOneSDKContext.shortcorrtime = 1800000l;
targetOneSDKContext.enableNotification = true;
targetOneSDKContext.enableLocation = true;
targetOneSDKContext.urlPrefix = "rcdp-us-east-1/rcdp-app2";
targetOneSDKContext.tenantHash = "TENANT_HASH";
targetOneSDKContext.accessToken = "ACCESS_TOKEN";
TargetOneMobileSDK.getInstance().init(context, targetOneSDKContext);
}
To enable your app to handle location permission use the following code:
Copy
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[],
@NonNull int[] grantResults) { switch (requestCode) {
case 2: {
TargetOneMobileSDK.getInstance().onRequestPermissionsResult(context,requestCode, permissions, grantResults);
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) {
case 1: {
TargetOneMobileSDK.getInstance().onActivityResult(context, requestCode, resultCode, data);
break; } }}
Next Steps
You have successfully performed the basic Real-time CDP SDK integration with Android app and are now ready to automatically track clickstream events such as app launches and associate that information with profiles for each of your customers.