AMAPI SDK와 통합

Android Management API (AMAPI) SDK를 사용하면 특정 앱이 Android 기기 정책 (ADP)과 직접 통신할 수 있습니다. 여기에는 다음에 대한 지원이 포함됩니다.

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

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

기본 요건

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

쿼리 요소 추가

앱이 SDK 30 이상을 타겟팅하는 경우 ADP와 상호작용하도록 지정하려면 AndroidManifest.xml에 쿼리 요소가 필요합니다.

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

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

NotificationReceiverService 구현

일부 기능은 NotificationReceiverService를 만들어야 하며, 일부 기능은 선택적으로 사용합니다. 이를 사용하려면 NotificationReceiverService를 확장하는 클래스를 정의하고 AndroidManifest.xml에 service로 추가한 후 내보내야 합니다.


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