1

I read Bluetooth LE ScanFilters don't work on Android M, but it doesnt solve my problem

I am scanning my app on nexus 5 (os: 6.0.1). I keep getting following message in logcat

BluetoothUtils: Permission denial: Need ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION permission to get scan 

Gradle file has following settings:

android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
    applicationId "XX.XX.XX"
    minSdkVersion 19
    targetSdkVersion 21
    versionCode 16
}

I am not using API 23 (or above) any where in my gradle but my phone has 6.0.1 OS.

Also, I have following defined in AndroidManifest

   <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
   <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

I donot ask for runtime permissions as specified in this blog because, I am targeting API 21 http://developer.radiusnetworks.com/2015/09/29/is-your-beacon-app-ready-for-android-6.html (when I tried to ask runtime permissions anyway, I get compiler warnings; so I am using GPS instead in the code)

How can I get rid of this warning from logcat

Permission denial: Need ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION permission to get scan results
Community
  • 1
  • 1
mobileDev
  • 1,358
  • 2
  • 14
  • 34
  • 1
    this http://stackoverflow.com/a/37015725/5188159 might help u even if u add permissions on manifest try to prompt it again manually and see – Charuක Oct 09 '16 at 01:24
  • Earlier, i added the code for permissions from the blog post of the link you referred. But I had compiler issues, bcos my gradle build is targeted towards 21. Am I missing anything? – mobileDev Oct 09 '16 at 05:17
  • Could it be, that you deactivated location in the settings? In order to receive ble scan results you need to have the location active. – p2pkit Oct 10 '16 at 11:59
  • I always get the scan results (at least on Nexus5). However only sometimes, randomly, I get these warnings. – mobileDev Oct 11 '16 at 01:51

0 Answers0