The ManageEngine Mobile APM Insight SDK for Android helps you monitor the performance and stability of your native Android applications on real user devices. It provides actionable insights into app behaviour and supports seamless integration with both Java and Kotlin applications.
Gain deep insights into your application's health and performance:
Once integrated, the SDK enables you to:
| Requirement | Minimum |
|---|---|
| Android SDK (compileSdk) | API 21 (Lollipop) or higher |
| Java | 1.8+ |
| AndroidX | Required (android.useAndroidX=true in gradle.properties) |
| ManageEngine Applications Manager - Mobile App monitor | An active monitor with a valid AppKey |
Before you can add ManageEngine APM Insight Android SDK to your Android app, you need to create a Mobile App monitor and download the configuration (apm_config.json) file from the Applications Manager web.
Groovy (build.gradle)
dependencies {
implementation "com.manageengine.apminsight:mobileapm:3.0.0"
}dependencyResolutionManagement {
repositories {
google()
mavenCentral()
maven {
url = uri("https://maven.zohodl.com/")
content {
includeGroup("com.manageengine.apminsight")
}
}
}
}<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />/**
* Initializes the ME APM Insight agent.
* @param context The application context.
*/
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
MEAPMInsight.initMonitoring( this );
}
}Note: If the SDK is initialized after application startup, pass an active Activity instance as the context to ensure immediate screen and lifecycle monitoring.
The ManageEngine APM Insight SDK automatically captures all uncaught exceptions. Each crash report includes the timestamp of occurrence and the complete stack trace to assist in root cause analysis.
MEAPMInsight.enableErrorReporting();Detect Application Not Responding (ANR) events, situations where the main (UI) thread is blocked for too long, causing Android to show the "App isn't responding" dialog to the user. ANR monitoring must be enabled using the below API:
// Default timeout (5 seconds)
MEAPMInsight.startANRWatching();
// Custom timeout// Report ANR if the main thread is blocked for more than 3 seconds
MEAPMInsight.startANRWatching(3000);
//Stop ANR Monitoring
MEAPMInsight.stopANRWatching();
}Option 1: Enable Globally
MEAPMInsight.enableFragmentSupport();Option 2: Enable for specific activities only
If you want fragment tracking enabled only for certain activities, register the lifecycle callbacks manually inside those activities:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.getSupportFragmentManager();
.registerFragmentLifecycleCallbacks(
new MEAPMInsightFragmentLifecycleCallbacks(),
true
);
}You can use the API below to set custom environment details for filtering data across various environment setups like development, debug, production, or release.
/**
*@param {String} environment
Custom environment types like debug, release, or beta release.
*/
MEAPMInsight.setEnvironment("release");Associate telemetry with a specific user. The SDK automatically hashes the user ID (SHA-256) before storing or transmitting it. By default, a unique user ID is generated by the SDK. If you want to customize user IDs, you can do so by implementing the following syntax. This comes in handy when you want to track metrics or debug issues specific to a particular user.
Important Note: Do not pass raw Personally Identifiable Information (PII) such as email addresses, phone numbers, or real names. Use an opaque identifier like an internal user ID or UUID instead.
/**
*@param {String} userId
*/
MEAPMInsight.setUserId("user_12345");The SDK automatically monitors network requests performed through the following libraries without additional configuration:
java.net.HttpURLConnectionjavax.net.ssl.HttpsURLConnectionOkHttp (when the SDK interceptor is added)OkHttpClient client = new OkHttpClient.Builder()
.addNetworkInterceptor(new MEAPMInsightInterceptor())
.build();If your application uses a custom networking layer or libraries that are not automatically monitored, you can manually track HTTP calls using the following API:
/**
* @param {String} url
* The complete request URL.
*
* @param {String} requestMethod
* The HTTP method used (e.g., GET, POST, PUT, DELETE).
*
* @param {long} startTime
* The request start time in milliseconds.
* You can obtain this using System.currentTimeMillis().
*
* @param {long} loadTime
* The total time taken to complete the request, measured in milliseconds.
*
* @param {int} responseCode
* The HTTP response status code returned by the server.
*
* @param {String} screen
* The name of the screen from which the HTTP call was initiated.
*/
Apm.addHttpCalls(
"https://www.example.com",
"GET",
System.currentTimeMillis(),
526,
200,
"PaymentScreen"
);By default, the SDK automatically captures all screens (Activities). If a screen is not detected automatically, you can manually track it using the API below:
/**
*@param {String} screenName
*@param {String} orientation
*@param {long} loadTime measured in millis
*@param {long} startTime measured in millis
*/
Apm.addScreen("DetailScreen", "portrait", 50, 1642743078700); Start a transaction using Apm.startTransaction("Transaction_Name") before a long-running operation and call stop() when it completes.
Transactions are:
When the same operation runs multiple times using the same transaction name, the SDK records the average execution time across those occurrences.
Use clear, consistent names to track business operations accurately.
/**
* Transaction
*
* @param {String} transactionName
* A meaningful name representing the overall business operation.
*
* Component
*
* @param {String} componentName
* A descriptive name for the sub-operation being measured.
*
* @param {int} componentType
* Predefined component type (e.g., Component.TYPE_HTTP).
*/
Transaction transaction = Apm.startTransaction("List Articles");
// Start predefined HTTP component
Component httpComponent = transaction.startComponent(Component.TYPE_HTTP);
// Start custom component
Component articlesComponent = transaction.startComponent("Download Articles");
// Download articles
transaction.stopComponent(articlesComponent);
for (Article article : articles) {
Component thumbnailComponent =
transaction.startComponent("Download Thumbnail");
// Download thumbnail
transaction.stopComponent(thumbnailComponent);
}
// Stop HTTP component
transaction.stopComponent(httpComponent);
// Stop transaction
Apm.stopTransaction(transaction);Use the API below to immediately upload the recorded telemetry data to the server instead of waiting for the next scheduled upload cycle. By default, the SDK uploads data at 60-second intervals.
MEAPMInsight.flush();Specific URLs can be excluded from tracking by passing a list of those URLs to the API below.
/**
@param {Lis<String>} listOfUrls
*/
MEAPMInsight.excludeHttpCalls(Arrays.asList("example.com"));Custom screens can be excluded from tracking by passing a list of screen names to the API below.
/*
* param
* List<String> listOfScreens
*/
MEAPMInsight.excludeScreens(Arrays.asList("customScreenName"));Use the API below to stop all data collection (screens, HTTP calls, transactions, crashes, ANR detection).
MEAPMInsight.stopMonitoring();The SDK automatically masks the values of known sensitive query parameters and headers, replacing them with ***** before any data is sent to the server. The following keys will be masked automatically:
To add custom sensitive keys, use the API below:
List<String> customSensitiveKeys = Arrays.asList("x-custom-token", "account_id", "ssn");
MEAPMInsight.addSensitiveParams(customSensitiveKeys);If you use code obfuscation, add the following rules to your proguard-rules.pro file:
-keep class manageengine.mobileapm.android.apm.** { *; }
-dontwarn manageengine.mobileapm.android.apm.**It allows us to track crucial metrics such as response times, resource utilization, error rates, and transaction performance. The real-time monitoring alerts promptly notify us of any issues or anomalies, enabling us to take immediate action.
Reviewer Role: Research and Development