Development issue/problem:

I am developing an application that uses Bluetooth Low Energy with a Nexus 5. He worked on Lollipop and now he’s not working on Marshmallow.
I set the permissions ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION in the manifesto and at runtime in Activity.

Here is a list of ScanFilters :

mScanFilterTest = new ScanFilter.Builder().build() ;
mScanFilter = new ArrayList() ;
mScanFilter.add(mScanFilterTest) ;

It’s a trap:

mScanSettings = new ScanSettings.Builder().setScanMode(ScanSettings.SCAN_MODE_LOW_POWER).setReportDelay(0)
.setCallbackType(ScanSettings.CALLBACK_TYPE_ALL_MATCHES).build() ;

These are my memories:

mBLEScan = new ScanCallback() {
public blank onScanResult(int callbackType, ScanResult result) {
super.onScanResult(callbackType, result);
Log.i(TAG, ******************************************);
Log.i(TAG, The scan result + result);
Log.i(TAG, TAG, ——————————————);

It’s my decision:

mBluetoothLeScanner.startScan (mScanFilter, mScanSettings, mBLEScan) ;

He starts scanning, but can’t find any devices.
Help me !!!!

How can I solve this problem?

Solution 1:

I faced the same problem. To solve the problem, enable the location (GPS) function in the phone settings and request the location authorization in the running application. In order for the scanning process to run smoothly, both steps have to be gone through.

To request permission for a location, type the following in the dialog box or As :

yourActivity.requestPermissions(new String[]{Manifest.permission.ACCESS_COARSE_LOCATION}, yourPermissionRequestCode) ;

and its implementation:

@Public Void Check
onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults){
if(requestCode == yourPermissionRequestCode)
… // Detect something based on the results of the grant}

in YourActivity and process whatever the user selects. You must also follow these steps to activate the device localization services:

Enable intentionLocationIntent = new intention(Settings.ACTION_LOCATION_SOURCE_SETTINGS) ;
yourActivity.startActivityForResult(enableLocationIntent, yourServiceRequestCode) ;

You can use the implementation to check if the user has activated location services:

protected void onActivityResult(int requestCode, int resultCode, intent data)
if(requestCode == yourServiceRequestCode)
..//Do anything you need to

in your activities. You can also manually activate location-based services (GPS):

Go to Phone settings -> Select Location -> Then turn it on.

In the phone settings it should look like this:

Bluetooth Low Energy startScan on Android 6.0 does not find devices –

Or maybe it’s like this in the quick settings:

Bluetooth Low Energy startScan on Android 6.0 does not find devices –

As soon as the user has activated the rights and started the location-based services, you should start scanning. I have noticed that if you are already scanning while activating/deactivating the location service, there is still nothing to see in the onScan results.

I’m not sure if this is a bug or a feature of the iBeacons / Bluetooth advertising (NOTE: advertising in the sense of selling products, not technical Bluetooth advertising) so companies can see your location and lead you where they want.

I hope this solves your problem!

EDITI wanted to add to that: You just need it for everything. Once you are connected to a BLE device, you can turn off the location service on your phone and still be connected to your devices. However, you will not be able to detect or connect new devices, and all adware devices will be removed from onScanResults.

Solution 2:

As @Jacopo Tosi says, you have to ask permission for the place.
You can read how to do it here.
And you have to activate the place, too. I don’t know why he did it. But it’s the only way to make it work.

Solution 3:

In my case (HTC M9) I also had to go to the Android settings menu under Bluetooth and manually scan BT devices.

Good luck!

android ble scan filter example,android ble startscan,ble blessed,android bluetooth gatt error 133,android ble connection timeout,ble-scanner android github,android ble scan-example,android bluetoothlescanner example,ledevicelistadapter,android ble sample project,btscanner android,android ble pendingintent,ble android,android ble read characteristic example,bluetooth low energy scanner android,bluetoothlegatt,android ble pairing example,bluetoothlescanner example,bluetoothlescanner example kotlin,android bluetooth onscanfailed,onscanresult ble,onscanresult ble android,sweetblue toolbox,android bluetoothlescanner tutorial,android studio bluetooth le scanner,bluetooth scan,android 10 ble scan not working,android ble library,bluetoothlescanner,android 10 ble permissions,android 10 bluetooth scanning

You May Also Like

How to Stop Getting Emails from Quora

Quora is a good platform to get answers to your questions. Many…

How to Turn On Camera or Microphone on Facebook Messenger Windows 10

Unlike the Facebook Messenger application on our smartphones or tablets where you…

Jabra Elite 85h vs Sony WH-1000XM3 : Headset Comparison

For the average customer on the subcontinent who spends more than fifteen…

How to Root HTC U12+ Plus and Install TWRP Recovery 3.4.0

If you own an HTC U12+ Plus (Codename: Image/ Ime) and want…