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]
> **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](https://developers.google.com/nearby/messages/android/user-consent.md.txt#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());
    }