10

I'm trying to develop Android Management API + kiosk app.

I want to get the device id(enterprises/xxxxx/devices/xxxxx) from the kiosk app.
My purpose is to associate the device id with the kiosk app id created in app.

Can I get the device id from the kiosk app? Is there any other solution?

STAR_ZERO
  • 1,400
  • 11
  • 21
  • 2
    I'm not sure you can fetch the `device id` directly from your Kiosk app. But you could create a Managed Configuration for you Kiosk app, then push the `device id` through it. – Florian Mar 19 '19 at 14:56
  • 1
    I would also recommend using managed configurations, I added a more detailed answer below to explain it. – Fred Mar 19 '19 at 22:52

3 Answers3

5

It is not possible for your app to directly access the device ID.

However you can achieve a similar result by exposing a managed configuration in your app with one string and configuring it in the ApplicationPolicy with a different policy for each device. The managed configuration can contain a string property that you set to the device ID for each device.

The managed configuration file in your app would look like:

<restrictions xmlns:android="http://schemas.android.com/apk/res/android">

  <restriction
    android:key="deviceId"
    android:title="ID of the device"
    android:restrictionType="string" />

</restrictions>

And the policy would look like:

{
  "applications": [
    {
      "packageName": "com.example",
      "installType": "FORCE_INSTALLED",
      "managedConfiguration": {
        "deviceId": "1a2b3c4d5e6f"
      }
    }
  ]
}

In addition, to set the policy as soon as a new device is enrolled you can set up Pub/Sub notifications and listen for ENROLLMENT events, the data field of the notification contains a Device resource with the device ID, therefore allowing you to create a new policy and assign it to the device.

Fred
  • 2,191
  • 1
  • 12
  • 14
  • 4
    While this approach works, it's a bit cumbersome. Is there any way to use Android Management API and have a custom developed app with permission to retrieve more information about the device, enterprise etc from the DPC? – Hameno Oct 29 '19 at 18:39
  • @Hameno Did you find out if it is possible to retrieve the extra information (e.g. device, enterprise) from the Android app? – H.T. Koo Jul 08 '20 at 09:04
  • 3
    Do you guys able to get the details form the android app? – Prasanth Ravi Aug 10 '20 at 12:37
  • 1
    This is very limiting, isn't it? If a certain policy-change should be applied to `X` devices, then `X` policies should be patched (rather than just 1). **Is there a way to get around that?** – Bliss Dec 22 '20 at 19:00
  • This is unnecessarily complex. It is very basic thing that we need. If I need to remove policy from one user how will I know that users device. There should be an easy way management api team. – Cembora Nov 07 '22 at 11:15
  • Was this ever addressed? Is it possible to obtain a managed device's unique Id after enrollment? – Alon Minski Nov 15 '22 at 12:14
1

I don't agree with this solution, as far i know people are reading policy information from device and map it with Kiosk Application.

Vaimeo
  • 1,078
  • 9
  • 14
0

You can get the device id easily from the app. Just search how to get "Google Service Framework ID". You will come to know that both are same. Let me know if this solves your query...!

Vinith Jain
  • 35
  • 1
  • 8
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 21 '22 at 18:02
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/33454964) – Rumit Patel Dec 25 '22 at 06:41