Applause SDK Production Installation Guide for Android

Applause SDK Production Installation Guide for Android

Android Installation (Production) DEPRECATED

Step 1 – Integrate the Mobile SDK

Please see: https://help.applause.com/hc/en-us/articles/204856785

Step 2 – Modify the Manifest File

Special Notes:

  • Gradle Users: No changes
  • Maven Users: You can merge the manifest if the <mergeManifests> flag is set to: true

Example:

<plugin>
      <groupID>com.jayway.maven.plugins.android.generation2</groupId>
      <artifactID>android-maven-plugin</artifactID>
      <version>3.8.2</version>
            <extensions>true</extensions>
      <configuration>
          <!-- add the following mergeManifests option -->
          <mergeManifests>true</mergeManifests>
      </configuration>
</plugin>

Add Required Permissions

Note: If you are using Maven or Gradle, you can skip this step.

The Applause SDK requires the INTERNET permission to connect with the Applause SDK server.

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

Optional Permissions

Note: We strongly recommend enabling the READ_PHONE_STATE permission. This is necessary to obtain the device ID (such as the IMEI) which the Applause SDK uses to identify each device uniquely on the server.

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

Note: We also strongly recommend adding the GET_TASKS permission. This is necessary for the Applause SDK to determine when your application has ended and needs to shutdown.

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

Optional Permissions

  • Connectivity Information

Will allow the SDK to collect detailed connectivity information including supported network interfaces, type of network (WiFi, 3G, etc.), WiFi Signal Strength, and more.

<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
  • Device Information

This will allow the SDK to collect basic information about the device, like DeviceID and IMEI.

<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
  • Geo-Location Information

These allow the Applause SDK to report location information based on both coarse references (the location of the nearest mobile network tower) and precise references (such as GPS).

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
  • Bluetooth Information

This allows the Applause SDK to report information about the device’s Bluetooth interface, including its state (on/off) and pair/unpair events.

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

See the Android security docs for more information about app permissions.

Manifest Example:

After applying the changes listed above, your AndroidManifest.xml should look a lot like the example below.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.helloworldandroid"
    android:versionCode="1"
    android:versionName="1.0">
    <uses-sdk android:minSdkVersion="7" android:targetSdkVersion="15" />
 
   <!-- Permissions required by the Applause SDK -->
   <uses-permission android:name="android.permission.INTERNET"/>
   <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
   <uses-permission android:name="android.permission.GET_TASKS" />
   <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
   <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
   <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
   <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
   <uses-permission android:name="android.permission.BLUETOOTH"/>
   <!-- ... rest of your application's permissions, if any -->
 
   <application
      android:icon="@drawable/ic_launcher"
      android:label="@string/app_name"
      android:theme="@style/AppTheme" >
 
   <activity
     android:name=".MainActivity">
      <intent-filter>
         <action android:name="android.intent.action.MAIN"></action>
         <category android:name="android.intent.category.LAUNCHER"></category>
      </intent-filter>
   </activity>

</application>   
</manifest>

Step 3 – Start an Applause SDK Session

Each time your app launches, you should start a new Applause SDK session. The only action to take is to invoke the Applause.startNewSession() method in the onCreate event of your application instance

First, make sure you import the Applause SDK:

import android.app.Application;
import com.applause.android.Applause;
import com.applause.android.config.Configuration;
// Optionally import the Applause SDK logging functions
import com.applause.android.Log;

// This invokes the Applause SDK when the application launches

public class MyApplication extends Application {
 
   final String APP_KEY = "Your-Application-Key-Goes-Here";
 
   @Override
   public void onCreate() {
       super.onCreate();
       Configuration configuration = new Configuration.Builder(this) 
           .withAPIKey("Your-Application-Key-Goes-Here") 
           .withMode(Applause.Mode.MARKET) 
           .build(); 
       Applause.startNewSession(this, configuration);
   }
}

Step 4 – Add Your Application Key

In order to send data to the Applause SDK, you’ll need to have a valid Applause SDK application key. If you do not already have an Applause SDK account, create one now. Once your account is created, log into http://sdk.applause.com, create a new product, and an App Key will be automatically generated for you. Existing app key can be found by clicking on the Product Settings icon and choosing “App Settings”

appsettings

appkey

In the above code, replace the string Your-Applause-SDK-Application-Key-Goes-Here with your actual Applause SDK application key.

Step 5 – Send Your Log Calls to the Applause SDK

The Applause SDK allows you to manually log events to the Applause SDK server. This can be useful when you are debugging problems or crash reports because you can track custom defined activities from your application.

The Applause SDK comes with its own logging library com.applause.Log, which you can use in place of the standard Android logging library. This class mimics the standard android.util.Log and has the same interfaces including the Log.v, Log.d, Log.i, Log.w and Log.e methods. Also, the Applause SDK’s logging methods will still send your data to Logcat.

The easiest way to have all your logs go through the Applause SDK is to replace the import statement:

import android.util.Log;

with

import com.applause.Log;

Step 6 (optional) – Customize Server URL

This step is ONLY needed if you need to target a server other than the default server (which is: https://sdk.applause.com).

Example: Those developers who are NOT also using Applause testing services and so are not currently integrated with the Applause 360 Dashboard. These ‘stand-alone’ SDK users should target ‘https://aph.applause.com‘. In the below example, “Your-Server-Url-Goes-Here” would be replaced with “https://aph.applause.com”.

This code should be added to the same file within which you’re starting the SDK (as per Step 3)

import com.applause.android.config.Configuration;

Configuration configuration = new Configuration.Builder(this)    
              .withAPIKey("Your-Application-Key-Goes-Here")  
              .withMode(Applause.Mode.MARKET)              
              .withServerURL("Your-Server-Url-Goes-Here")                
              .build();        

Applause.startNewSession(this, configuration);