Code Monkey home page Code Monkey logo

Comments (15)

chengjiamei avatar chengjiamei commented on June 5, 2024 1

Thank you first, i am sure that i had enable Location and make it be ON. And i used setUseHardwareBatchingIfSupported with false, but it does not work too .

from android-scanner-compat-library.

Jai-GAY avatar Jai-GAY commented on June 5, 2024

there is no code on how you did the scanning, could you have accidentally turn on the scan filter ?
could it be that other devices already connected and not yet disconnect before SAMSUNG start scanning ?

scanner.startScan(filters, settings, nordic_scanCallback);

hope it is helpful.

from android-scanner-compat-library.

chengjiamei avatar chengjiamei commented on June 5, 2024

Thank you for response,and i confirm that the device had not connected.The same problem is found on nRf toolbox and nRf Connect when i tested!
Follow is my code

        final BluetoothLeScannerCompat scanner = BluetoothLeScannerCompat.getScanner();
        final ScanSettings settings = new ScanSettings.Builder()
                .setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY).setReportDelay(1000).setUseHardwareBatchingIfSupported(false).build();
        List<ScanFilter> scanFilters = new ArrayList<>();
        if(mIsScanning) {
            cancelLeScan();
        }
        if(scanCallback == null) {
            scanCallback = new MyScanCallBack();
        }
        scanner.startScan(scanFilters, settings, scanCallback);
        mIsScanning = true;
        mHandler.postDelayed(new Runnable() {
            @Override
            public void run() {
                if (mIsScanning) {
                    cancelLeScan();
                }
            }
        }, SCAN_DURATION);

There are any problem? Thank you again.

from android-scanner-compat-library.

philips77 avatar philips77 commented on June 5, 2024

Try passing null as filters, instead of an empty array.
Are you sure you have and granted the location permission (coarse it fine) if using Marshmallow or newer?

from android-scanner-compat-library.

chengjiamei avatar chengjiamei commented on June 5, 2024

I am sure i had granted the location permission and i tested on Android 6.0. I will change the param according to your advice and test again.Thank you very much!

from android-scanner-compat-library.

chengjiamei avatar chengjiamei commented on June 5, 2024
``09-18 09:46:41.677 19958-19958/com.isport.isporttracker D/BluetoothLeScanner: Start Scan
09-18 09:46:41.678 19958-19958/com.isport.isporttracker D/BluetoothAdapter: STATE_ON
09-18 09:46:41.679 19958-19958/com.isport.isporttracker D/BluetoothAdapter: STATE_ON
09-18 09:46:41.680 19958-19958/com.isport.isporttracker D/BluetoothAdapter: STATE_ON
09-18 09:46:41.681 19958-19958/com.isport.isporttracker D/BluetoothAdapter: STATE_ON
09-18 09:46:41.787 19958-19971/com.isport.isporttracker D/BluetoothLeScanner: onClientRegistered() - status=0 clientIf=5 mClientIf=0
09-18 09:46:42.674 19958-19958/com.isport.isporttracker E/BleService: onBatchScanResults  size = 0
09-18 09:46:43.677 19958-19958/com.isport.isporttracker E/BleService: onBatchScanResults  size = 0
09-18 09:46:44.679 19958-19958/com.isport.isporttracker E/BleService: onBatchScanResults  size = 0
09-18 09:46:45.681 19958-19958/com.isport.isporttracker E/BleService: onBatchScanResults  size = 0
09-18 09:46:46.684 19958-19958/com.isport.isporttracker E/BleService: onBatchScanResults  size = 0
09-18 09:46:47.687 19958-19958/com.isport.isporttracker E/BleService: onBatchScanResults  size = 0
09-18 09:46:48.690 19958-19958/com.isport.isporttracker E/BleService: onBatchScanResults  size = 0
09-18 09:46:49.693 19958-19958/com.isport.isporttracker E/BleService: onBatchScanResults  size = 0
09-18 09:46:50.696 19958-19958/com.isport.isporttracker E/BleService: onBatchScanResults  size = 0
09-18 09:46:51.698 19958-19958/com.isport.isporttracker E/BleService: onBatchScanResults  size = 0
09-18 09:46:51.799 19958-19958/com.isport.isporttracker D/BluetoothAdapter: STATE_ON
09-18 09:46:51.801 19958-19958/com.isport.isporttracker D/BluetoothAdapter: STATE_ON
09-18 09:46:51.803 19958-19958/com.isport.isporttracker D/BluetoothAdapter: STATE_ON
09-18 09:46:51.805 19958-19958/com.isport.isporttracker D/BluetoothAdapter: STATE_ON
09-18 09:46:51.805 19958-19958/com.isport.isporttracker D/BluetoothLeScanner: Stop Scan

the size that return in onBatchScanResults always is zero, even on-off bluetoothadapter.
the scan method is

        final BluetoothLeScannerCompat scanner = BluetoothLeScannerCompat.getScanner();
        final ScanSettings settings = new ScanSettings.Builder()
                .setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY).setReportDelay(1000).setUseHardwareBatchingIfSupported(false).build();
        scanner.startScan(null, settings, scanCallback);
        mIsScanning = true;
        mHandler.postDelayed(new Runnable() {
            @Override
            public void run() {
                if (mIsScanning) {
                    cancelLeScan();
                }
            }
        }, SCAN_DURATION);

I tested on SAMSUM S7 and S6.
When it happened, it happened on nrf Connect too.
What should i do.

from android-scanner-compat-library.

philips77 avatar philips77 commented on June 5, 2024

Did you try to enable Location in Android drop down menu? Some devices require it to be ON. Doesn't matter what accuracy you set. Also, you may try using https://github.com/NordicSemiconductor/Android-Scanner-Compat-Library/blob/master/scanner/src/main/java/no/nordicsemi/android/support/v18/scanner/ScanSettings.java#L401 with false, as batching fails on some devices. This will, however, impact battery usage.

from android-scanner-compat-library.

farruxx avatar farruxx commented on June 5, 2024

Same issue with stock android 7.1 frimwares on xperia

from android-scanner-compat-library.

trongkhanh avatar trongkhanh commented on June 5, 2024

BluetoothLeScanner on android 6.0.1 (ss s6 edge) cannot found device android >= 6.0.1

i had enable permission for App in AndroidManifest.xml file as following:

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

from android-scanner-compat-library.

philips77 avatar philips77 commented on June 5, 2024

Hello,
Did you manage to solve the issue?
Did you requested Location runtime permission? You may grant it Settings -> Applications -> Your app -> Permissions -> switch the Location switch to ON and try scanning.

from android-scanner-compat-library.

philips77 avatar philips77 commented on June 5, 2024

HI, did you manage to solve the issue?

from android-scanner-compat-library.

Strife91 avatar Strife91 commented on June 5, 2024

Did you try to enable Location in Android drop down menu? Some devices require it to be ON. Doesn't matter what accuracy you set. Also, you may try using https://github.com/NordicSemiconductor/Android-Scanner-Compat-Library/blob/master/scanner/src/main/java/no/nordicsemi/android/support/v18/scanner/ScanSettings.java#L401 with false, as batching fails on some devices. This will, however, impact battery usage.

Might I ask why some devices requires it to be on and others not?

from android-scanner-compat-library.

philips77 avatar philips77 commented on June 5, 2024

Well... it should be required in all phones. The Location setting is a master switch for all location based features of the phone.
But some manufacturers decided to do otherwise. As Android is open source, they are free to do so. Actually, Samsung now also requires it in Android Pie+.

from android-scanner-compat-library.

Strife91 avatar Strife91 commented on June 5, 2024

Well... it should be required in all phones. The Location setting is a master switch for all location based features of the phone.
But some manufacturers decided to do otherwise. As Android is open source, they are free to do so. Actually, Samsung now also requires it in Android Pie+.

I just thought it was strange because only the OnePlus 3 of the 6 different devices I've tried requires it to be on, even the Nexus 5X does not even though it is vanilla Android, so it's strange that google doesn't enforce it themselves.

And I'm not required to have location enabled when I use bluetooth headsets even though they are bluetooth 4.1.

I just want some clarity here.

And what do you think is the best solution? I don't want to ask the user to enable location on devices that does not require it to be on. So is there some kind of check I can do to see if location must be enabled on this particular device?

from android-scanner-compat-library.

philips77 avatar philips77 commented on June 5, 2024

Location is required only for scanning Bluetooth LE devices. Your headset is Classic Bluetooth and perhaps already paired.

Check what we do in nRF Blinky. We start scanning initially showing a warning to enable Location, but if we find a device despite it being disabled, we save internally that the phone doesn't need it and no longer allow it.

from android-scanner-compat-library.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.