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.
Nearby Messages API có thể tiêu tốn nhiều pin do cách API này sử dụng Bluetooth và các tài nguyên khác của thiết bị để phát hiện và giao tiếp với các thiết bị ở gần. Để đảm bảo người dùng có quyền kiểm soát trải nghiệm, một hộp thoại chọn tham gia sẽ xuất hiện trong lần đầu tiên người dùng truy cập vào API Tin nhắn lân cận.
Người dùng phải đồng ý để tính năng Nearby sử dụng các tài nguyên thiết bị bắt buộc.
Chỉ BLE
Bạn có thể tránh hộp thoại chọn sử dụng nếu ứng dụng của bạn đã được cấp quyền ACCESS_FINE_LOCATION và chỉ sử dụng BLE trong quá trình phát hành và đăng ký.
[null,null,["Cập nhật lần gần đây nhất: 2025-08-29 UTC."],[[["\u003cp\u003eThe Nearby Messages API requires user consent to utilize device resources due to potential battery consumption from Bluetooth and other resource usage.\u003c/p\u003e\n"],["\u003cp\u003eAn opt-in dialog is presented upon first API access, requiring explicit user permission.\u003c/p\u003e\n"],["\u003cp\u003eThe opt-in dialog can be bypassed if the app only uses Bluetooth Low Energy (BLE), has been granted ACCESS_FINE_LOCATION permission, and is configured with the NearbyPermissions.BLE option.\u003c/p\u003e\n"]]],[],null,["# Handling User Consent\n\nThe Nearby Messages API has the potential to be battery-intensive due to the way\nit uses Bluetooth and other device resources to detect and communicate with\nnearby devices. To ensure that users are in control of the experience, an opt-in\ndialog is presented the first time the user accesses the Nearby Messages API.\nThe user must provide consent for Nearby to utilize the required device\nresources.\n| **Note:** The opt in dialog won't be shown if you only use BLE, and your app has ACCESS_FINE_LOCATION permissions. See [BLE Only](#ble_only) for an example.\n\nBLE Only\n--------\n\nYou can avoid the opt in dialog if your app has been granted the\nACCESS_FINE_LOCATION permission and only uses BLE during publishes and\nsubscribes. \n\n if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)\n == PackageManager.PERMISSION_GRANTED) {\n mMessagesClient = Nearby.getMessagesClient(this, new MessagesOptions.Builder()\n .setPermissions(NearbyPermissions.BLE)\n .build());\n }"]]