Android SDK

Overview

Real-time CDP offers an Android SDK that enables you to track user behavior, capture clickstream events, enrich customer profiles, and deliver personalized experiences such as push notifications and In-App Notifications.

The SDK integrates directly into your application and sends structured event data to rCDP in real time. This ensures that mobile data is unified with web and backend data for a complete customer view.

Note: The Android SDK follows the same standardized event taxonomy used across all integrations.

How It Works

  1. Add the SDK to your Android project

  2. Configure dependencies and permissions

  3. Initialize the SDK during application launch

  4. Capture user interactions and events

  5. Send data to rCDP for processing and activation

Tip: Initialize the SDK as early as possible to ensure complete session tracking.

SDK Integration Flow

  • SDK Installation

  • SDK Integration

  • SDK Initialization

  • SDK Methods

Follow these steps to successfully integrate and use the SDK within your Android application. :contentReference[oaicite:0]{index=0}

SDK Installation

Add dependency from the catalog to the application. Once the catalog is added, include the SDK dependency as shown below.

Add TargetOneMobileSDK.aar file in the libs folder in your project.

dependencies {
implementation files('libs/TargetOneMobileSDK.aar')
}
			

Note: Ensure the .aar file is correctly added to avoid build issues.

SDK Integration

Follow the steps below to integrate the SDK into your Android application.

Step 1: Add Dependencies

dependencies {
implementation 'com.android.support:cardview-v7:27.1.1-alpha1'
implementation 'com.github.bumptech.glide:glide:3.6.1'
implementation 'com.google.code.gson:gson:2.4'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.volley:volley:1.1.0'
implementation 'com.google.firebase:firebase-core:16.0.9'
implementation 'com.google.firebase:firebase-messaging:18.0.0'
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.android.support:support-v4:27.1.1'
}
			

Step 2: Enable MultiDex

android {
defaultConfig {
multiDexEnabled true
}
}
			

Step 3: Add Google Services Plugin

apply plugin: 'com.google.gms.google-services'
			

Step 4: Configure Firebase

Add the google-services.json file to your project to enable push notifications.

Note: Firebase configuration is required for push messaging capabilities.

Step 5: Update Manifest

Add the Firebase messaging service in your AndroidManifest.xml file to enable push notification handling.

<service android:name="com.manthan.targetone.service.MyFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
			

Note: This service enables the SDK to receive and process Firebase push notifications.

Step 6: Add Permissions

Add the required permissions in your AndroidManifest.xml file.

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
			

Note: These permissions are required for network communication, location tracking, and device-level operations.

SDK Initialization

Initialize the SDK during application launch to start tracking events and user interactions.

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 = "sandbox/rcdp-app2";
targetOneSDKContext.tenantHash = "TENANT_HASH";
targetOneSDKContext.accessToken = "ACCESS_TOKEN";

TargetOneMobileSDK.getInstance().init(context, targetOneSDKContext);
}
			

Tip: Initialize the SDK in the Application class or Splash Activity.

Configuration Details

  • tenantHash: Unique tenant identifier

  • accessToken: Authentication token

  • urlPrefix: Endpoint configuration

  • enableNotification: Enables push notifications

  • enableLocation: Enables location tracking

Handling Runtime Permissions

Use the following method to handle runtime permission responses:

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[],
@NonNull int[] grantResults) {
switch (requestCode) {
case 2: {
TargetOneMobileSDK.getInstance().onRequestPermissionsResult(
context, requestCode, permissions, grantResults
);
}
}
}
			

Handling Activity Results

Use the following method to handle activity results required by the SDK:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case 1: {
TargetOneMobileSDK.getInstance().onActivityResult(
context, requestCode, resultCode, data
);
break;
}
}
}
			

SDK Methods

The Android SDK provides a set of core methods that enable you to capture user behavior, manage customer data, and deliver real-time engagement experiences within your application.

These methods form the foundation of your integration and allow you to track user interactions, build unified customer profiles, and trigger contextual messaging.

The key SDK methods supported are:

Note: These methods work together to provide a complete view of user behavior and enable real-time personalization across channels.

Customer Profiles

Customer customer = new Customer(); 
customer.setCustomerCode("12345");
customer.setEmail("abc@gmail.com");
customer.setMobileNo("4544454445"); 
TargetOneMobileSDK.getInstance().setCustomerProfile(context, customer);
			

Tip: Always set the customer profile after login.

Clickstream Events

TargetOneMobileSDK.getInstance().sendClickStream(context, eventType, eventData, (APIResponseInterface)this);
			

Handle API Response

Use the following APIResponseInterface method to enable API response callback.

@Override
public void onCallback(int statusCode, JSONObject jsonObject) {
/* Here statusCode refers to StatusCode of API Response
&
jsonObject refers to JSONObject Response for realtime API
*/
}
			

In-App Notifications

In-App Notifications are configured from the dashboard and displayed automatically by the SDK.

Block In-App Notifications

TargetOneSDKContext.blockInApp.add(String ActivityName);
			

Send FCM Token

public void onNewToken(String s) {
TargetOneMobileSDK.getInstance().registerFcmToken(getApplicationContext(), s);
}
			

Handle Push Notifications

if (!TargetOneMobileSDK.getInstance().handleFcmNotification(getApplicationContext(), remoteMessage))
{
Log.v(TAG, "Notification Not From TargetOne");
}
			

Best Practices

  • Initialize the SDK early

  • Set customer profile after login

  • Validate event data

  • Test on real devices

  • Ensure Firebase configuration is correct