Singular Fraud SDK - Android

Please note before starting:

  • The latest version of the SDK supports Android 4.0.1 (Ice Cream Sandwich) and above. Make sure you are using a compatible Android framework version. If you choose to use the SDK with an older Android version, Singular's support team may not be able to assist you if any issues arise.
  • Singular’s SDK reports using the Android Advertising ID for devices using PlayStore v4. Older devices will continue to report using the Android ID.

Downloading the SDK

Direct Download

Download the latest version (9.2.7).

Using Gradle

Add our repository:

repositories {
    jcenter()
    maven { url 'http://maven.singular.net/' }
}

Add our library to the dependencies list:

dependencies {
    compile 'com.google.android.gms:play-services:6.5.87'
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.3'
    ...
    compile 'com.singular.sdk:singular_sdk:9.2.7'
    ...
}

Integrating the Fraud SDK

Adding the Necessary Permissions

The Singular SDK needs the following permissions, which you should add under <manifest> in your AndroidManifest.xml file:

  • INTERNET - Required
    <uses-permission android:name="android.permission.INTERNET" />
  • ACCESS_NETWORK_STATE - Required
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

Note: If an app is utilizing the permission to "retrieve running apps", this may cause the app to be initialized after download but before the user opens the app for the first time. This will also initialize the Singular SDK before the first open, causing discrepancies in the recorded install time. We recommend removing this permission if it is not needed or moving the Singular Initialization method out of the flow to only initialize Singular when the user opens the app.

<uses-permission android:name="android.permission.GET_TASKS" />

Initializing Singular Functionality

Importing the Singular Library

Start off by importing the Singular library:

import com.singular.sdk.*;

Create a SingularConfig object using your ApiKey & Secret and pass to the Singular.Init Method:

@Override
protected void onCreate(Bundle savedInstanceState)
{
    // Other code
            
    // Init Singular SDK
    SingularConfig config = new SingularConfig("yourApiKey", "yourApiSecret");
    Singular.init(context, config); //context is Application Context
    
    // Other code
}

Notes:

  • From the Application class, you can pass this or getApplicationContext() as the context.
  • To get the Application Context from inside an activity you can call currentActivity.getApplicationContext()*.
  • The init() method should be called at every entry point in the app, no matter which activity initializes the app. Calling init() in the application’s onCreate is best.
Was this article helpful?
0 out of 0 found this helpful