ผสานรวมกับ AMAPI SDK
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
SDK ของ Android Management API (AMAPI) ช่วยให้แอปบางแอปสื่อสารกับ Android Device Policy (ADP) ได้โดยตรง
โดยจะรองรับการใช้งานต่อไปนี้
คุณต้องทำตามขั้นตอนต่อไปนี้เพื่อผสานรวม AMAPI SDK กับแอปพลิเคชัน
- เพิ่มไลบรารี AMAPI SDK
- เพิ่มองค์ประกอบการค้นหา หาก SDK เป้าหมาย >= 30
ข้อกำหนดเบื้องต้น
- ตรวจสอบว่าได้ตั้งค่า
minSdkVersion
ของแอปเป็น API ระดับ 21 เป็นอย่างน้อย
- เพิ่มการอ้างอิงสำหรับ AMAPI SDK เวอร์ชันล่าสุดลงในแอปพลิเคชัน
คุณดูเวอร์ชันของไลบรารีล่าสุดที่พร้อมใช้งานและ
วิธีเพิ่มลงในแอปพลิเคชันได้ในหน้าหมายเหตุประจำรุ่นของ AMAPI SDK
เพิ่มองค์ประกอบการค้นหา
หากแอปกำหนดเป้าหมายเป็น SDK 30 ขึ้นไป คุณจะต้องมีองค์ประกอบ queries ใน
AndroidManifest.xml
เพื่อระบุว่าแอปจะโต้ตอบกับ ADP
<queries>
<package android:name="com.google.android.apps.work.clouddpc" />
</queries>
ดูข้อมูลเพิ่มเติมได้ที่การกรองระดับการมองเห็นแพ็กเกจใน Android
ใช้ NotificationReceiverService
ฟีเจอร์บางอย่างต้องสร้างNotificationReceiverService
และบางฟีเจอร์
จะใช้หรือไม่ก็ได้ หากต้องการใช้ ให้กำหนดคลาสที่ขยาย NotificationReceiverService
เพิ่มเป็น service
ใน AndroidManifest.xml
และตรวจสอบว่าได้ส่งออกแล้ว
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.
}
}
ใน AndroidManifest.xml
ให้เพิ่ม
<service
android:name = ".MyAppNotificationReceiverService"
android:exported = "true" />
โดยปกติแล้ว เราต้องส่ง ComponentName
ของคลาสที่ใช้
NotificationReceiverService
ให้เราผ่าน API ที่เหมาะสม
รายละเอียดจะแตกต่างกันไปตามฟีเจอร์ที่เป็นปัญหา และแต่ละฟีเจอร์ที่ต้องใช้เอกสารนี้จะระบุไว้
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-08-28 UTC
[null,null,["อัปเดตล่าสุด 2025-08-28 UTC"],[],[],null,["The [Android Management API (AMAPI) SDK](https://maven.google.com/web/index.html#com.google.android.libraries.enterprise.amapi) enables specific apps to\ncommunicate directly with Android Device Policy (ADP). It includes support for:\n\n- [Local execution of Commands](/android/management/sdk-local-commands)\n- [Migrate devices managed with a custom DPC to AMAPI](/android/management/dpc-migration)\n- [Device Trust from Android Enterprise](/android/management/device-trust-api)\n- New device enrollment flow that also supports adding managed Google Accounts\n- [Manage custom apps with AMAPI](/android/management/manage-custom-apps)\n\nThe following steps must be taken to integrate the AMAPI SDK with your\napplication:\n\n1. [Add the AMAPI SDK library](/android/management/sdk-release-notes#declare_dependencies).\n2. [Add the queries element](#add_queries), if target SDK \\\u003e= 30.\n\n| **Note:** If you are developing an extension app, you will also need to provision the device with an [extensibility policy](/android/management/sdk-local-commands#policy).\n\nPrerequisites\n\n- Verify that your app's `minSdkVersion` is set to at least API level 21.\n- 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](/android/management/sdk-release-notes) page.\n\nAdd queries element\n\nIf your app targets SDK 30 or later, then queries element is needed in the\n`AndroidManifest.xml` to specify that it will interact with ADP. \n\n \u003cqueries\u003e\n \u003cpackage android:name=\"com.google.android.apps.work.clouddpc\" /\u003e\n \u003c/queries\u003e\n\nSee [Package visibility filtering on Android](https://developer.android.com/training/package-visibility) for more information.\n\nImplement a NotificationReceiverService\n\nSome features require creating a\n[`NotificationReceiverService`](/android/management/reference/amapi/com/google/android/managementapi/notification/NotificationReceiverService), and some features\nmake optional use of it. To use it, define a class extending\n`NotificationReceiverService`, add it as a `service` to your\n`AndroidManifest.xml`, and make sure it is exported. \n\n\n import com.google.android.managementapi.notification.NotificationReceiverService;\n\n ...\n\n public final class MyAppNotificationReceiverService extends NotificationReceiverService {\n\n @Override\n protected void setupInjection() {\n // This method can be optionally used to inject dependencies at the\n // beginning of the service lifecycle.\n }\n }\n\nIn your `AndroidManifest.xml`, add \n\n \u003cservice\n android:name = \".MyAppNotificationReceiverService\"\n android:exported = \"true\" /\u003e\n\nTypically the `ComponentName` of your class which implements\n`NotificationReceiverService` needs to be passed to us through a suitable API.\nThe details vary depending on the feature in question, and each feature which\nneeds this documents it."]]