Android integration manual

Example Gradle configuration:

To add the library to the project put an aar file in libs catalog and modify gradle.Build file
Parameter ‘name’ in the ‘compile’ section should be named the same as the library file without the extension.

repositories {
        flatDir {
            dirs 'libs'
    dependencies {
        compile(name:'appmanagolibrary-release', ext:'aar')

For other tools configuration check how to add the external library to the project in their documentation.

List of dependencies used by the library:


Library configuration

In the strings.xml file of integrated application add the following entries:

  • appmanago_launch_time
    It defines the time interval between successive uses of the module/function after which we
    assume that the application was restarted. The value is given in minutes.


    <string name="appmanago_launch_time">30</string>

    For 30 – launch event will be registered when the application has been inactive for 30 minutes and then resumed.

  • appmanago_sync_meantime
    It/ Variable/ The entry defines how often the platform should make an attempt to synchronize events, which took place when there was no Internet connection. The value is given in minutes.


    <string name="appmanago_sync_meantime">360</string>

    In the example application will try to synchronize every 360 minutes.

  • appmanago_endpoint
    It/ Variable/ The entry defines the endpoint. Default endpoint for SALESmanago Mobile is


    <string name="appmanago_endpoint"></string>
  • appmanago_vendor_id
    Vendor identificator; itan be found after logging in to the SALESmanago Mobile panel Settings -> Account.


    <string name="appmanago_vendor_id">VENDOR_ID</string>
  • appmanago_application_id
    Simple ID of the application.The ID is created when you add a new application to Create app panel.


    <string name="appmanago_application_id">APPLICATION_SIMPLE_ID</string>
  • appmanago_gps_sync_time
    Minimal interval between sending GPS coordinates (in minutes).


    <string name="appmanago_gps_sync_time">1</string>
  • appmanago_gps_front_available
    Flag determining whether the location should be updated continuously or only when the application is active (0 – still, 1 – only when the application is active).


    <string name="appmanago_gps_front_available">0</string>
  • appmanago_gps_accuracy
    Accuracy of location determination and also battery consumption:
    – HIGH – high accuracy, the device will determine the most accurate location,
    – BALANCED – (recommended) – accuracy up to 100m with the best ratio of performance to battery consumption,
    – LOW – accuracy up to 10km, low battery consumption,
    – PASSIVE – passive mode, the application is waiting for the location to be updated by other applications, it does not use energy to determine it,
    (to avoid battery drain, location system has 10s timeout – if within 10 second location is not resolved, process will be canceled)


    <string name="appmanago_gps_accuracy">HIGH</string>

Transferring events to SALESmanago Mobile

Events are transferred via AmMonitoring interface. The initialization of such an object looks as shown below and takes place under the onCreate() method:

private AmMonitoring amMonitor;
amMonitor = AmMonitor.initLibrary(getApplicationContext());

AmMonitor objects should be created per module as they contain components responsible for measuring the time spent in the module (Activity).

Additionally, the onResume() and onPause() methods, required to measure the time spent in a given module, must be overridden. The module name must be the same as the one defined on the SALESmanago Mobile platform.

  protected void onResume() {
    amMonitor.eventStarted(MODULE_NAME, new AmProperties());

  protected void onPause() {
    amMonitor.eventEnded(MODULE_NAME, new AmProperties());

Starting from library version 3.7.0, the code line provided below must be added to the Activity class of the module that is displayed to the user first (i.e., the starting screen):


where CONTEXT is the application context – a global context tied to the lifecycle of an application, providing access to application-level resources and services.

The above code line should be placed in the onCreate method, preferably directly after calling the super.onCreate(savedInstanceState) method, as shown below:

public class FirstScreenActivityClass extends Activity {
   public void onCreate(Bundle savedInstanceState) {
       ActivityLifecycleListener.registerActivityLifecycleCallback((Application) getApplicationContext());

Integration with Firebase Cloud Messaging (FCM)

To add FCM to the application one must execute client’s manual on Google page:

In order to receive Server API Key and Sender ID one should register the application. Then, add API and ID to the GCM account in SALESmanago Mobile. Those values can be found in Settings -> Cloud Messaging after logging in to the project in the Firebase console. One should also integrate the android project with FCM using the ready tool in Android Studio Tools -> Firebase -> Cloud Messaging.

The next step is adding the permissions and services to AndroidManisfest.xml:

                <action android:name="" />

Additionally, check the Google Api service for onCreate() method.

        if (checkPlayServices()) {

Implementation is as follows:

       private boolean checkPlayServices() {
        GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
        int resultCode = apiAvailability.isGooglePlayServicesAvailable(this);
        if (resultCode != ConnectionResult.SUCCESS) {
            if (apiAvailability.isUserResolvableError(resultCode)) {
                apiAvailability.getErrorDialog(this, resultCode, 9000)
            } else {
                Log.i(Constants.LOG_TAG, "This device is not supported.");
            return false;
        return true;

Rich notification

It is able to add rich notification to push e.g. a image. In create push it is necessary to check “Rich content” checkbox and add needed attributes. It is recommended to make it custom but it is possible to use the default implementation. For default in SALESmanago Mobile library when it is received push with rich notification with type “jpg” or “png” and link to picture then it will show this image below notification.

To use custom rich notification it is need to override richPushNotification() method in class PushActionExecutor To do this it is necessary to change class in AndroidManifest.xml com.appmanago.lib.fcm.AmFirebaseListenerService to new class that creates instead PushActionExecutor its extension with override richPushNotification() method.


Beacons are avaiable on Android since Android Lollipop when it supports Bluetooth LE. It is need to add to AndroidManifest.xml permissions to Bluetooth:

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

In place where we start to search for beacons we need to initialize SALESmanago Mobile library to support searching beacons:

    amBeaconMonitor = AmBeaconMonitor.initLibrary(getApplicationContext());

Before search it is needed to check if:

– Android version is above or equals Lollipop
– Bluetooth is reached in device and it is on

       mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
       if(mBluetoothAdapter != null && mBluetoothAdapter.isEnabled()) {
           mBluetoothLeScanner = mBluetoothAdapter.getBluetoothLeScanner();

To stop searching Beacons:


The methods used to monitor customer behavior:

amMonitor.eventStarted(ACTIVITY_NAME, amProperties);

is used during the launch of the module / (Activity). ACTIVITY_NAME is simpleID from SALESmanago Mobile.
Usually the method will be called in the method onResume() where it’ll start to start count duration of the module usage.

amMonitor.eventEnded(ACTIVITY_NAME, amProperties);

is used at the end of (Activity) module execution.
Usually it will be used in the method OnPause() where it’ll stop counting the time of module usage.

amMonitor.eventCustom(CUSTOM_EVENT_NAME, amProperties);

is used during the custom events transfer. The events should be defined in SALESmanago Mobile as custom events as well.

amMonitor.clicked(FUNCTION_NAME, amProperties);

is used during the launch of methods mapped in SALESmanago Mobile. It will count how many times function was used. You can add details like date as amProperties.


is used to add user’s email address. The email will be used as user’s ID on the platform.


is used to add users phone number/MSISDN.


It sends user properties to SALESmanago Mobile. It is a key-value map where we can store data about user, e.g., name, surname, shoe number or birthdate. We can use this data to personalize push notifications, and set the dynamic segments.

amMonitor.sendLocation(WIDTH, LENGTH);

is used to send users’location.

    AmExtras amExtras = amMonitor.getAmExtras(bundle)

It allows the application to read the type and content of payload from the notification. It is executed when user receives a push. A developer can use the data from payload to e.g., redirect to app’s module, send an event, view an image, and many more.

If you need more information about the topic mentioned above, please contact us: +1 800 960 0640