Questions? Feedback? powered by Olark live chat software

Android SDK

The Android SDK collects data from Android mobile applications and transmits the collected data to Simility software. Simility provides a pre-built JAR file, which you must include in your Android application project.

In the app runtime, when the SDK is invoked, the required data is collected and sent to the Simility software asynchronously in the background thread without affecting the user interface operations.

The data from the application is collected based on the manifest permissions set in the host application. The SDK explicitly does not request permissions to access and collect any data.

You can follow any one of the procedures below to configure the Android SDK in the Android Studio IDE.

Configuring using the JCenter Repository

  1. In the dependencies block of your build.gradle file, add the following line:
    compile ‘com.simility.recon:simility-recon:1.611’
  2. Clean the build.
  3. Import and call the Simility APIs with applicable parameters.
  4. Build and run the application.

Configuring using the New Module

  1. Download the .aar file and extract it.
  2. Create a new project or open your existing project.
  3. Click File>New>Import Module.
  4. In the Source directory box, select the extracted .aar file
  5. In the dependencies block of your build.gradle file, add the following line:
    compile ‘com.simility.recon:simility-recon:1.611’
  6. Clean the build.
  7. Import and call the Simility APIs with applicable parameters.
  8. Build and run the application.

Sample Code

package com.example.androidintegratiodemo;

import android.app.Activity;
import android.os.Bundle;

// Import SimilityScript and SimilityContext
import com.simility.recon.SimilityScript;
import com.simility.recon.SimilityContext;

public class MainActivity extends Activity {

  @Override
    protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      // Construct a valid SimilityContext
      SimilityContext similityContext = new SimilityContext();
      similityContext.setApplicationContext(getApplicationContext());
      similityContext.setCustomerId("5e295f6c-5fd2-11e7-907b-a6006ad3dba0"); // replace  with unique identifier assigned by Simility. This will be provided to you during signup.
      similityContext.setSessionId("your.session.id.variable"); //replace with sessionID variable
      similityContext.setUserId("your.user.id.variable"); //replace with userID variable
      similityContext.setEventTypes("payment_initiate"); // Comma separated snake_case string of action/event which is associated with this activity/view.
      similityContext.setZone("us"); // Default: "us". If data regulatory compliance requires your data to be hosted in Europe datacenters, please specify zone as "eu" 

      // Execute SimilityScript
      SimilityScript.getInstance().execute(similityContext);
    }
}

SimilityContext Class

Use the class to create a Simility context with required methods and pass it to the SimilityScript class below as a parameter.

In the SimilityContext class, you can add the following methods. These methods are applicable for both IDEs (Eclipse and Android Studio).

+ setApplicationContext Method
Description Sets the application context.
Syntax
public void setApplicationContext(Context applicationContext);
Parameters
Name Type Description
applicationContext Context TBD.
Example
similityContext.setApplicationContext(getApplicationContext());
+ setCustomerId Method
Description Sets the customer ID.
Syntax
public void setCustomerId(customerId);
Parameters
Name Type Description
customerId String Specify the UUID provided by Simility.
Example
similityContext.setCustomerId("5e295f6c-5fd2-11e7-907b-a6006ad3dba0");
+ setEventTypes Method
Description Sets the type of the event.
Syntax
public void setEventTypes(eventTypes);
Parameters
Name Type Description
eventTypes String Specify the event or action that you want to associate with the JavaScript. You can specify multiple values separated with a comma.
Example
similityContext.setEventTypes("payment_initiate");
+ setSessionId Method
Description Sets the session ID.
Syntax
public void setSessionId(sessionId);
Parameters
Name Type Description
SessionId String Specify a unique session ID assigned to the user sessions when users accessed your application.
Example
similityContext.setSessionId("your.session.id.variable");
+ setZone Method
Description Sets the zone where your data centers are hosted.
Syntax
public void setZone(zone);
Parameters
Name Type Description
zone String Specify the zone where your datacenters are hosted.
Example
similityContext.setZone("us");

SimilityScript Class

Use the class to execute the created Simility context.

+ execute Method
Description Executes the specified Simility context.
Syntax
public static void execute(SimilityContext similityContext);
Parameters
Name Type Description
similityContext Context Specify the name of the Simility context that you want to execute.
Example
SimilityScript.execute(similityContext);