kaiwalya
kaiwalya

Reputation: 15

Android Settings API turn on bluetooth to improve location accuracy?

I have use new Settings API to turn on GPS without to leave my application. My LocationRequest looks like this:

LocationRequest mLocationRequest = new LocationRequest(); mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

everything works fine but dialog prompts me to enable bluetooth too (along with GPS) Is there way to only enable GPS?

Upvotes: 0

Views: 479

Answers (2)

redlee90
redlee90

Reputation: 21

I found the same issue here. And I have to find a walk around this by first turn on bluetooth in an intent and then from the callback to request location.

private boolean isBluetoothEnabled() {
    if (mBluetoothAdapter != null && !mBluetoothAdapter.isEnabled()) {
        Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
        int REQUEST_ENABLE_BT = 1;
        startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
        return false;
    }
    return true;
}

Upvotes: 0

Prince Champappilly
Prince Champappilly

Reputation: 333

I suspect that in your LocationSettingsRequest you are mistakenly requesting BLE support.

LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder() .addLocationRequest(mLocationRequestHighAccuracy) .addLocationRequest(mLocationRequestBalancedPowerAccuracy);

builder.setNeedBle(true);

If the client is using BLE scans to derive location, it can request that BLE be enabled by calling setNeedBle(boolean):

If you do not want BLE then set this to false or remove this line.

Upvotes: 1

Related Questions