Logo
Android Behaviour SDK
To initialise the SDK add the below line of code with the public key you retrieved from Sense client panel. If you don't have a public key create new one and call that below function.
How to Install
toast-icon
Requirements
  1. Use Android 7.0 (API level 21) and above.
  2. Use Kotlin version 1.6.10 and above: example ext.kotlin_version = '1.6.10'
  1. Maven Installation
    copy-icon
    copy-icon
    repositories {
        ...
        mavenCentral()
        maven { url 'https://central.sonatype.com/artifact/ai.gosense/behaviour' }
    }
    Check out maven for latest version of maven versions.
  2. Add Dependency build.gradle file
    copy-icon
    copy-icon
    dependencies {
        implementation 'ai.gosense:behaviour:0.0.2'
    }
    Sync Gradle to synchronize all the dependencies in your Android project.
  3. Import SDK
    copy-icon
    copy-icon
    import ai.gosense.behaviour.SenseBehaviour
    import ai.gosense.behaviour.SenseBehaviourConfig
    import ai.gosense.behaviour.SenseBehaviourListener
    Sync Gradle to synchronize all the dependencies in your Android project.
  4. Initialize SDK
    Add the following line of code to initialize it with the api key you obtained from the Sense Client panel. If you don't have a api key create new one
    copy-icon
    copy-icon
    val config = SenseBehaviourConfig(
        apiKey = "your API Key",
        reference_id = "your reference ID",
        sense_id = "your sense ID",
        metaInfo = mutableMapOf(
            "device" to "XXXXXXXX",
            "session" to System.currentTimeMillis()
        ),
        optional = mutableMapOf(
            "enableTouches" to false, // true or false
            "enableInputs" to false, // true or false
            "enableButtons" to false // true or false
        )
    )
    SenseBehaviour.initSDK(this, config)
    SenseBehaviour.startTracking(this as Activity)
  5. Get Device Behaviour Details
    copy-icon
    copy-icon
    SenseBehaviour.getBehaviourData(context,this)
    Use the below code to get the Device Behaviour Details.
  6. Implement Listener
    Set and Implement our listener to receive the Callback details.
    copy-icon
    copy-icon
    override fun onFailureBehaviour(message: String) {
        // failure callback
    }
    override fun onSuccessBehaviour(data: String) {
        // success callback 
    }
  7. Progurad Rules (Optional)
    If you encounter any problem in your integration related to Proguard, you can use add the below lines Proguard Rules.
    copy-icon
    copy-icon
    # Keep OkHttp
    -keep class okhttp3.** { *; }
    -keep class okio.** { *; }
    -dontwarn okhttp3.**
    -dontwarn okio.**
  8. Sample Program
    Here you can find the demonstration to do the integration.
    copy-icon
    copy-icon
    import ai.gosense.behaviour.SenseBehaviour
    import ai.gosense.behaviour.SenseBehaviourConfig
    import ai.gosense.behaviour.SenseBehaviourListener
    
    class MainActivity : ComponentActivity(), SenseBehaviourListener {
    
          override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
          setContentView(R.layout.activity_main)
          val context:Context = this
    
         val config = SenseBehaviourConfig(
            apiKey = "your API Key",
            reference_id = "your reference ID",
            sense_id = "your sense ID",
            metaInfo = mutableMapOf(
                "device" to "XXXXXXXX",
                "session" to System.currentTimeMillis()
            ),
            optional = mutableMapOf(
                "enableTouches" to false, // true or false
                "enableInputs" to false, // true or false
                "enableButtons" to false // true or false
            )
        )
        SenseBehaviour.initSDK(this, config)
        SenseBehaviour.startTracking(this as Activity)
        
        myButton.setOnClickListener {
        SenseBehaviour.getBehaviourData(context,this)
         }
       }
    
        override fun onFailureBehaviour(message: String) {
        // failure callback
        }
        override fun onSuccessBehaviour(data: String) {
            // success callback 
        }
    }