Documentation

This documentation provides a step-by-step guide on how to integrate the TesterMob library into your Android project.

Github: https://github.com/testermob/Android-Library

Setup Instructions

Follow these steps to set up the TesterMobLib in your project.

First, download the TesterMobLib.aar file from the following link:

Download TesterMob Library (.aar)

Then, add the TesterMobLib.aar file to the app/libs/ directory of your Android project.

implementation files('libs/TesterMobLib.aar')

Also, add the following libraries to your build.gradle file:

implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
                

AndroidManifest Permissions

Before using the TesterMob library, you need to add the necessary permissions in your AndroidManifest.xml file.

In your AndroidManifest.xml file, you need to add the following permissions:

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

Main Activity

To use the tracker, implement it in your MainActivity class.

In the MainActivity class, add the following code before the onCreate() method:

public static UserActivityTracker tracker;
public String appId = "app_id"; // copy your app id from dashboard

Inside the onCreate() method, add the following code:

tracker = new UserActivityTracker(this, appId);
tracker.sendUserActivity(appId);
tracker.getTesterMob();
                

OnResume and OnStop Methods

These methods are essential for tracking user activity in the app.

In the MainActivity, add the following methods:

@Override
protected void onResume() {
    super.onResume();
    tracker.sendUserActivity(appId);
}

@Override
protected void onStart() {
    super.onStart();
    tracker.startTracking();
}

@Override
protected void onStop() {
    super.onStop();
    tracker.stopTracking();
}
                

Other Activities

To track user activity in other activities, implement the tracker as follows:

In other activities, also add the following code before the onCreate() method:

@Override
protected void onStart() {
    super.onStart();
    tracker.startTracking();
}

@Override
protected void onStop() {
    super.onStop();
    tracker.stopTracking();
}
                

© 2024 - , This template improved with   by Testermob.com