Các quyền bắt buộc
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Ứng dụng của bạn phải khai báo quyền cho từng phương thức API được sử dụng. Các quyền bắt buộc sẽ khác nhau. Điều này phụ thuộc vào các phương thức API và loại hàng rào mà ứng dụng của bạn sử dụng. Hãy tham khảo tài liệu này để tìm hiểu những quyền cần thiết cho từng phương thức.
Snapshot API
Bảng sau đây cho biết các quyền cần thiết cho từng phương thức API tổng quan:
Phương thức |
Quyền bắt buộc trên Android |
getDetectedActivity() |
android.permission.ACTIVITY_RECOGNITION
com.google.android.gms.permission.ACTIVITY_RECOGNITION
(Android 9 (API cấp 28))
|
getBeaconState() |
android.permission.ACCESS_FINE_LOCATION |
getHeadphoneState() |
không có |
getLocation() |
android.permission.ACCESS_FINE_LOCATION |
Fence API
Bảng sau đây cho biết các quyền cần thiết cho từng loại hàng rào của API hàng rào:
Loại hàng rào Fence API |
Quyền bắt buộc trên Android |
DetectedActivityFence |
android.permission.ACTIVITY_RECOGNITION
com.google.android.gms.permission.ACTIVITY_RECOGNITION
(Android 9 (API cấp 28))
|
BeaconFence |
android.permission.ACCESS_FINE_LOCATION |
HeadphoneFence |
không có |
LocationFence |
android.permission.ACCESS_FINE_LOCATION |
TimeFence |
không có |
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-08-31 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-08-31 UTC."],[[["\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 |"]]