所需权限
您的应用必须声明所使用的每种 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 栅栏类型所需的权限:
围栏 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 |
无 |
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2023-09-14。
[null,null,["最后更新时间 (UTC):2023-09-14。"],[[["Your app must declare permissions for each Awareness API method used, with specific permissions varying based on the method and fence type."],["Refer to the provided documentation to identify the necessary permissions for each Awareness API method."],["The Snapshot API requires specific permissions for accessing detected activities, beacon state, and location, while headphone state requires no permission."],["The Fence API requires specific permissions for activity, beacon, and location fences, while headphone and time fences require no permission."]]],["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"]]