question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Location needs to be enabled for BLE Scanning on Android 6.0

See original GitHub issue

Just going to report this here for others.

Related to: https://stackoverflow.com/questions/33045581/location-needs-to-be-enabled-for-bluetooth-low-energy-scanning-on-android-6-0

Apparently the solution is: I solved this by setting targetSdkVersion to 22 in gradle file. You must declare ACCESS_COARSE_LOCATION in the manifest but, BLE scanning will work even if user denies this permission from App Settings.

However my targetSdkVersion was set to 24 so I cannot downgrade my app or Google Play Console will complain.

Another solution would be if this library:

Can use BluetoothAdapter.startDiscovery().It will scan for both Bluetooth Smart and classic Bluetooth devices, but location services do not need to be enabled.(You still need ACCESS_COARSE_LOCATION permissions on Android 6.)

Thoughts about changing this?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:10

github_iconTop GitHub Comments

1reaction
dariuszseweryncommented, Sep 20, 2019

My question was if I targeted and used the Sdk 22 would it be possible to use this library without enabling location?

Yes — it would be possible. There are two caveats though:

  1. Google will not accept your app to the Play Store
  2. I am not sure how if the system would return you scan advertisements if the user has disabled location services / GPS switch
0reactions
omarbakeercommented, Sep 20, 2019

You should not ignore Location when searching for BLE devices

I really appreciate your support Dariusz, but my use case requires the minimum configuration, and I don’t need the location or any of its related features (like the rssi). My question was if I targeted and used the Sdk 22 would it be possible to use this library without enabling location? Thank you

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why do I need to turn on location services to pair with a ...
To fix that: revoke location permission from the app and toggle bluetooth off and on to disconnect; install "NRF Connect" from Play Store,...
Read more >
Location needs to be enabled for BLE Scanning on Android 6.0
You must declare ACCESS_COARSE_LOCATION in the manifest but, BLE scanning will work even if user denies this permission from App Settings.
Read more >
Bluetooth permissions - Android Developers
ACCESS_FINE_LOCATION is necessary because, on Android 11 and lower, a Bluetooth scan could potentially be used to gather information about the location of...
Read more >
Android – Location needs to be enabled for Bluetooth Low ...
After upgrading to Android version 6.0 Bluetooth Low Energy (BLE) scanning will only work if Location services are enabled on the device.
Read more >
BluetoothLeScanner.startScan require Location Service ...
P3, Get BLE scan result using 'BluetoothLeScanner.startScan' must open Location Service in Android 6.0. “ https://issuetracker.google.com/37065090 ”.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found