BluetoothLeScanner.startScan with Android 6.0 does not discover devices

前端 未结 6 890
小蘑菇
小蘑菇 2020-12-30 21:53

I\'m trying to use the function BluatoothLeScanner.startScan instead of the deprecated one BluetoothAdapter.startLeScan. Yesterday I updated my Nexus 5 to

6条回答
  •  难免孤独
    2020-12-30 22:20

    It's an old question, but I will answer to help someone.
    Unfortunately, the combination of ACCESS_COARSE_LOCATION and targetSdkVersion 22 does not work on some devices.
    This is not a good method, but I have solved it in the following way without using runtime permissions (ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION)

    1. Set your 'targetSdkVersion' to 19 (I think maybe api19 ~ api22 will be possible)
    2. Add the following permission to your manifest file

      
      
      

    tested to Android 4.4 ~ 7.1.1

提交回复
热议问题