The Android Management API (AMAPI) SDK enables specific apps to communicate directly with Android Device Policy (ADP). It includes support for:
- Local execution of Commands.
- Migrate devices managed with a custom DPC to AMAPI
- Device Trust from Android Enterprise
The following steps must be taken to integrate the AMAPI SDK with your application:
- Add the AMAPI SDK library.
- Add the queries element, if target SDK >= 30.
Prerequisites
- Ensure that your app's
minSdkVersion
is set to at least API level 21. - Add the dependencies for the latest version of the AMAPI SDK to your application. You can find the version of the latest available library, and how to add it to your application, in the AMAPI SDK's release notes page.
Add queries element
If your app targets SDK 30 or later, then queries element is needed in the
AndroidManifest.xml
to specify that it will interact with ADP.
<queries>
<package android:name="com.google.android.apps.work.clouddpc" />
</queries>
See Package visibility filtering on Android for more information.
Implement a NotificationReceiverService
Some features require creating a
NotificationReceiverService
, and some features
make optional use of it. To use it, define a class extending
NotificationReceiverService
, add it as a service
to your
AndroidManifest.xml
, and make sure it is exported.
import com.google.android.managementapi.notification.NotificationReceiverService;
...
public final class MyAppNotificationReceiverService extends NotificationReceiverService {
@Override
protected void setupInjection() {
// This method can be optionally used to inject dependencies at the
// beginning of the service lifecycle.
}
}
In your AndroidManifest.xml
, add
<service
android:name = ".MyAppNotificationReceiverService"
android:exported = "true" />
Typically the ComponentName
of your class which implements
NotificationReceiverService
needs to be passed to us through a suitable API.
The details vary depending on the feature in question, and each feature which
needs this documents it.