AMAPI SDK와 통합

Android Management API (AMAPI) SDK를 사용하면 특정 앱이 Android Device Policy (ADP)와 직접 통신할 수 있습니다. 다음 지원이 포함됩니다.

AMAPI SDK를 애플리케이션과 통합하려면 다음 단계를 따라야 합니다.

  1. AMAPI SDK 라이브러리를 추가합니다.
  2. 타겟 SDK가 30 이상인 경우 queries 요소를 추가합니다.

기본 요건

  • 앱의 minSdkVersion이(가) API 수준 21 이상으로 설정되어 있는지 확인합니다.
  • 최신 버전의 AMAPI SDK 종속 항목을 애플리케이션에 추가합니다. 사용 가능한 최신 라이브러리의 버전과 애플리케이션에 추가하는 방법은 AMAPI SDK 출시 노트 페이지에서 확인할 수 있습니다.

queries 요소 추가

앱이 SDK 30 이상을 타겟팅하는 경우 AndroidManifest.xml에 queries 요소가 필요하여 ADP와 상호작용함을 지정해야 합니다.

<queries>
    <package android:name="com.google.android.apps.work.clouddpc" />
</queries>

자세한 내용은 Android의 패키지 공개 상태 필터링을 참고하세요.

NotificationReceiverService 구현

일부 기능에는 NotificationReceiverService를 만들어야 하고 일부 기능에서는 선택적으로 사용할 수 있습니다. 이를 사용하려면 NotificationReceiverService를 확장하는 클래스를 정의하고 AndroidManifest.xmlservice로 추가한 후 내보내야 합니다.


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.
  }
}

ADP 앱에 NotificationReceiverService 클래스의 ComponentName를 제공해야 합니다. 이를 수행하는 방법에는 두 가지가 있습니다. 각 기능의 문서에는 사용할 접근 방식이 명시되어 있습니다.

명시적 API

이 경우 ComponentName이 적절한 API를 통해 ADP 앱에 전달됩니다. 해당 기능의 문서에 자세한 내용이 나와 있습니다. AndroidManifest.xml에 다음을 추가합니다.

<service
 android:name = ".MyAppNotificationReceiverService"
 android:exported = "true" />

자동 검색

이 방법을 사용하면 서비스가 자동으로 검색될 수 있도록 서비스를 태그해야 합니다. AndroidManifest.xml에 다음을 추가합니다.

<service
 android:name = ".MyAppNotificationReceiverService"
 android:exported = "true" >
    <meta-data android:name="Insert name here" android:value=""/>
</service>

meta-dataandroid:name에 사용할 특정 문자열은 이 접근 방식을 사용하는 각 기능에 대해 문서화되어 있습니다 (예는 애플리케이션 역할 관리 참고). 이 태그가 유효하려면 앱에 사용 설정되어 있고 meta-dataandroid:name이 이 특정 문자열이고 android:value이 빈 문자열인 서비스가 정확히 하나 있어야 합니다. 동일한 서비스에 meta-data를 여러 개 추가할 수 있습니다.