重要資訊:我們目前不接受新的 Play EMM API 註冊。
瞭解詳情。
Devices: setState
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
設定裝置是否已啟用 Google 服務存取權。只有在 Android 裝置強制執行 EMM 政策時,裝置狀態才會生效
已在 Google 管理控制台中啟用裝置。
否則,系統會忽略裝置狀態並允許存取所有裝置
。
這項功能僅適用於由 Google 管理的使用者。
要求
HTTP 要求
PUT https://www.googleapis.com/androidenterprise/v1/enterprises/enterpriseId/users/userId/devices/deviceId/state
參數
參數名稱 |
值 |
說明 |
路徑參數 |
deviceId |
string |
裝置的 ID。
|
enterpriseId |
string |
企業的 ID。
|
userId |
string |
使用者的 ID。
|
授權
此要求需要具有下列範圍的授權:
範圍 |
https://www.googleapis.com/auth/androidenterprise |
詳情請參閱「驗證與授權」網頁。
要求主體
在要求主體中,提供具有以下結構的資料:
{
"kind": "androidenterprise#deviceState",
"accountState": string
}
屬性名稱 |
值 |
說明 |
附註 |
accountState |
string |
裝置上的 Google 帳戶狀態。「已啟用」表示裝置上的 Google 帳戶可用於存取 Google 服務 (包括 Google Play),且「已停用」代表不能成功新裝置一開始會處於「停用」狀態。
可接受的值為:
|
|
kind |
string |
|
|
回應
如果成功的話,這個方法會傳回回應內文,其結構如下:
{
"kind": "androidenterprise#deviceState",
"accountState": string
}
屬性名稱 |
值 |
說明 |
附註 |
accountState |
string |
裝置上的 Google 帳戶狀態。「已啟用」表示裝置上的 Google 帳戶可用於存取 Google 服務 (包括 Google Play),且「已停用」代表不能成功新裝置一開始會處於「停用」狀態。
可接受的值為:
|
|
kind |
string |
|
|
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2024-09-12 (世界標準時間)。
[null,null,["上次更新時間:2024-09-12 (世界標準時間)。"],[[["\u003cp\u003eEnables or disables a device's access to Google services for Google-managed users.\u003c/p\u003e\n"],["\u003cp\u003eDevice state enforcement requires enabling EMM policies in the Google Admin Console.\u003c/p\u003e\n"],["\u003cp\u003eRequires authorization with the \u003ccode\u003ehttps://www.googleapis.com/auth/androidenterprise\u003c/code\u003e scope.\u003c/p\u003e\n"],["\u003cp\u003eUses a PUT request to update the device state to either "enabled" or "disabled".\u003c/p\u003e\n"]]],[],null,["# Devices: setState\n\n| **Note:** Requires [authorization](#auth).\n\nSets whether a device's access to Google services is enabled or disabled.\nThe device state takes effect only if enforcing EMM policies on Android\ndevices is enabled in the Google Admin Console.\nOtherwise, the device state is ignored and all devices are allowed access\nto Google services.\nThis is only supported for Google-managed users.\n\nRequest\n-------\n\n### HTTP request\n\n```\nPUT https://www.googleapis.com/androidenterprise/v1/enterprises/enterpriseId/users/userId/devices/deviceId/state\n```\n\n### Parameters\n\n| Parameter name | Value | Description |\n|----------------|----------|---------------------------|\n| **Path parameters** |||\n| `deviceId` | `string` | The ID of the device. |\n| `enterpriseId` | `string` | The ID of the enterprise. |\n| `userId` | `string` | The ID of the user. |\n\n### Authorization\n\nThis request requires authorization with the following scope:\n\n| Scope |\n|-----------------------------------------------------|\n| `https://www.googleapis.com/auth/androidenterprise` |\n\nFor more information, see the [authentication and authorization](/android/work/play/emm-api/v1/how-tos/authorizing) page.\n\n### Request body\n\nIn the request body, supply data with the following structure:\n\n```text\n{\n \"kind\": \"androidenterprise#deviceState\",\n \"accountState\": string\n}\n```\n\n| Property name | Value | Description | Notes |\n|----------------|----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------|\n| `accountState` | `string` | The state of the Google account on the device. \"enabled\" indicates that the Google account on the device can be used to access Google services (including Google Play), while \"disabled\" means that it cannot. A new device is initially in the \"disabled\" state. \u003cbr /\u003e Acceptable values are: - \"`disabled`\" - \"`enabled`\" | |\n| `kind` | `string` | | |\n\nResponse\n--------\n\nIf successful, this method returns a response body with the following structure:\n\n```text\n{\n \"kind\": \"androidenterprise#deviceState\",\n \"accountState\": string\n}\n```\n\n| Property name | Value | Description | Notes |\n|----------------|----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------|\n| `accountState` | `string` | The state of the Google account on the device. \"enabled\" indicates that the Google account on the device can be used to access Google services (including Google Play), while \"disabled\" means that it cannot. A new device is initially in the \"disabled\" state. \u003cbr /\u003e Acceptable values are: - \"`disabled`\" - \"`enabled`\" | |\n| `kind` | `string` | | |"]]