androidandroid-management-api

How to Efficiently List Non-Compliant Devices Using Android Management API?


I am building an EMM software for Android devices using the Android Management API. Currently, I'm listing all devices in the enterprise with the enterprises.devices.list method and checking each device's policyCompliant field to identify non-compliant devices.

Here is the approach I’m using:

var devices = androidManagementService.Enterprises.Devices.List("enterprises/enterpriseId").Execute();
foreach (var device in devices.Devices)
{
    if (!device.PolicyCompliant)
    {
        // Mark the device as non-compliant
        // Use nonComplianceReason from NonComplianceDetails
    }
}

This works, but I have to loop through all devices, which seems inefficient for large enterprises.

Is there a more efficient way to get a list of only non-compliant devices using the Android Management API, without retrieving all devices and filtering them manually?

Thank you!


Solution

  • Unfortunately, there isn’t a direct way to filter and retrieve only non-compliant devices, as the enterprises.devices.list method doesn’t support query filtering based on compliance status. If you want to optimize your endpoint, you may utilize methods like (e.g Pagination) by setting a smaller page size. This allows you to retrieve and process small batches of devices at a time, Additionally Android Management API supports query parameters for pageSize and pageToken. In order to minimize processing strain, it’s possible to adjust the pageSize parameter and handle the pageToken accordingly.