所需權限
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
應用程式必須為每個使用的 API 方法宣告權限。所需權限會有所不同。這取決於應用程式使用的 API 方法和圍欄類型。請參閱這份說明文件,瞭解每個方法需要哪些權限。
Snapshot API
下表列出各個 Snapshot API 方法所需的權限:
方法 |
必要的 Android 權限 |
getDetectedActivity() |
android.permission.ACTIVITY_RECOGNITION
com.google.android.gms.permission.ACTIVITY_RECOGNITION
(Android 9 (API 級別 28))
|
getBeaconState() |
android.permission.ACCESS_FINE_LOCATION |
getHeadphoneState() |
無 |
getLocation() |
android.permission.ACCESS_FINE_LOCATION |
Fence API
下表列出每個 Fence API 圍欄類型所需的權限:
Fence API 圍欄類型 |
必要的 Android 權限 |
DetectedActivityFence |
android.permission.ACTIVITY_RECOGNITION
com.google.android.gms.permission.ACTIVITY_RECOGNITION
(Android 9 (API 級別 28))
|
BeaconFence |
android.permission.ACCESS_FINE_LOCATION |
HeadphoneFence |
無 |
LocationFence |
android.permission.ACCESS_FINE_LOCATION |
TimeFence |
無 |
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-31 (世界標準時間)。
[null,null,["上次更新時間:2025-08-31 (世界標準時間)。"],[[["\u003cp\u003eYour app must declare permissions for each Awareness API method used, with specific permissions varying based on the method and fence type.\u003c/p\u003e\n"],["\u003cp\u003eRefer to the provided documentation to identify the necessary permissions for each Awareness API method.\u003c/p\u003e\n"],["\u003cp\u003eThe Snapshot API requires specific permissions for accessing detected activities, beacon state, and location, while headphone state requires no permission.\u003c/p\u003e\n"],["\u003cp\u003eThe Fence API requires specific permissions for activity, beacon, and location fences, while headphone and time fences require no permission.\u003c/p\u003e\n"]]],["Apps must declare permissions for each API method used, varying by method and fence type. The `getDetectedActivity()` Snapshot API method and `DetectedActivityFence` require `android.permission.ACTIVITY_RECOGNITION` and `com.google.android.gms.permission.ACTIVITY_RECOGNITION`. `getBeaconState()`, `getLocation()`, `BeaconFence`, and `LocationFence` require `android.permission.ACCESS_FINE_LOCATION`. `getHeadphoneState()`, `HeadphoneFence`, and `TimeFence` require no specific permissions. Consult the documentation for specific method permission requirements.\n"],null,["# Required permissions\n\nYour app must declare permissions for each API method that's used. The\nrequired permissions vary. It depends on the API methods and fence types\nused by your app. Reference this documentation to learn which permissions are\nrequired for each method.\n\nSnapshot API\n------------\n\nThe following table shows the permissions required for each Snapshot API\nmethod:\n\n| Method | Required Android permission |\n|-------------------------|-------------------------------------------------------------------------------------------------------------------------------|\n| `getDetectedActivity()` | `android.permission.ACTIVITY_RECOGNITION` `com.google.android.gms.permission.ACTIVITY_RECOGNITION` (Android 9 (API level 28)) |\n| `getBeaconState()` | `android.permission.ACCESS_FINE_LOCATION` |\n| `getHeadphoneState()` | none |\n| `getLocation()` | `android.permission.ACCESS_FINE_LOCATION` |\n\nFence API\n---------\n\nThe following table shows the permissions required for each Fence API fence\ntype:\n\n| Fence API fence type | Required Android permission |\n|-------------------------|-------------------------------------------------------------------------------------------------------------------------------|\n| `DetectedActivityFence` | `android.permission.ACTIVITY_RECOGNITION` `com.google.android.gms.permission.ACTIVITY_RECOGNITION` (Android 9 (API level 28)) |\n| `BeaconFence` | `android.permission.ACCESS_FINE_LOCATION` |\n| `HeadphoneFence` | none |\n| `LocationFence` | `android.permission.ACCESS_FINE_LOCATION` |\n| `TimeFence` | none |"]]