Send feedback
Handling User Consent
Stay organized with collections
Save and categorize content based on your preferences.
The Nearby Messages API has the potential to be battery-intensive due to the way
it uses Bluetooth and other device resources to detect and communicate with
nearby devices. To ensure that users are in control of the experience, an opt-in
dialog is presented the first time the user accesses the Nearby Messages API.
The user must provide consent for Nearby to utilize the required device
resources.
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 for an example.
BLE Only
You can avoid the opt in dialog if your app has been granted the
ACCESS_FINE_LOCATION permission and only uses BLE during publishes and
subscribes.
if ( ContextCompat . checkSelfPermission ( this , Manifest . permission . ACCESS_FINE_LOCATION )
== PackageManager . PERMISSION_GRANTED ) {
mMessagesClient = Nearby . getMessagesClient ( this , new MessagesOptions . Builder ()
. setPermissions ( NearbyPermissions . BLE )
. build ());
}
Send feedback
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License , and code samples are licensed under the Apache 2.0 License . For details, see the Google Developers Site Policies . Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-10-04 UTC.
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Missing the information I need"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Too complicated / too many steps"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Out of date"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Samples / code issue"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]
Need to tell us more?
{"lastModified": "Last updated 2024-10-04 UTC."}
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-10-04 UTC."]]