Bluetooth Discovery on Android

I've been trying the Bluetooth discovery code as suggested in the demo app and also built and tested the provided Zebra Demo app but the Discovery>Bluetooth option never finds anything.

My understanding from the API documentation is that the findPrinters() method in BluetoothDiscoverer will find any discoverable Bluetooth devices, not just printers.

I am using a Moto G Play phone running Android 7.1.1

I have Bluetooth enabled on the phone and if I go to Device Settings>Bluetooth I do see the Bluetooth devices both paired and unpaired.

The Link-OS SDK version is 2.14.5198.

The Zebra printer we are using is a ZQ520. The printer is listed in Settings > Bluetooth on the phone.

The problem is puzzling because the Zebra Setup Utility app is able to discover the printer, but the Zebra Demo app is not (Discovery>Bluetooth).

Is the Zebra Demo app code for Discovery>Bluetooth not up to date or not supposed to work ? Is the documentation at https://techdocs.zebra.com/link-os/2-14/android/content/com/zebra/sdk/pr... incorrect?

Steven Si
This is an issue that

This is an issue that developers encounter often when they just start to use Bluetooth on Android. Due to security and privacy, on Android you need to give the permission to the app for using Bluetooth. Please check out this article for details on how-to: Link-OS SDK for Android | Permissions and Bluetooth API.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Diana Diaconu
Unfortunately, that is not

Unfortunately, that is not the case and there must be some other reason. The app has the permissions but findPrinters() is never returning anything. The phone is paired with a printer and there are also other Bluetooth devices around. Neither printer nor the other devices are found. According to the documentation findPrinters() should detect/find all discoverable devices, not just printers. Maybe I am misunderstanding the documentation? I expected the provided Demo App's BluetoothDiscovery activity to work and discover the paired devices.
If instead of using BluetoothDiscoverer.findPrinters() I use the Android SDK's BluetoothAdapter a call to getBondedDevices() does return all the paired devices.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Steven Si
The BluetootDiscoverer

The BluetootDiscoverer.findPrinters() should find all discoverable Bluetooth. Here is the code snippet from an working example. Please make sure to run the discovery on a separate thread, not on the UI thread.

try {
    BluetoothDiscoverer.findPrinters(getActivity(), new DiscoveryHandler() {
        @Override
        public void foundPrinter(DiscoveredPrinter discoveredPrinter) {
            discoveredPrinters.add(discoveredPrinter);
            adapter.notifyDataSetChanged();
            Log.i(TAG, "Discovered a printer");
        }

        @Override
        public void discoveryFinished() {
            Log.i(TAG, "Discovery finished");
        }

        @Override
        public void discoveryError(String s) {
            Log.i(TAG, "Discovery error");
        }
    });
} catch (ConnectionException e) {
    Log.i(TAG, "Printer connection error");
}

In additon, the developer demo that comes with the Link-OS SDK release has the Bluetooth discovery demo. You can compile and load the demo on your device to see how it works.

Vote: 
Vote up!
Vote down!

Points: 1

You voted ‘up’


Diana Diaconu
Neither the Link-OS SDK demo

Neither the Link-OS SDK demo code nor the above finds the discoverable Bluetooth devices. The only callback invoked is discoveryFinished(). It is puzzling as I have 3 discoverable devices around that I can see in Android Settings>Bluetooth and that get discovered by the Android SDK's BluetoothAdapter.
There's obviously something I am missing as the BT permissions are there and the devices are discoverable. Maybe it's related to the Android OS version.

I have now changed our code to use the Android SDK's BluetoothAdapter for the device discovery, "pick the MAC address" from the returned list and only use Zebra from then on for the actual printing.

Thanks for your help.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Steven Si
Would you share the type of

Would you share the type of the Android device(s) you are using and the version of the Android OS on the device(s)? This is the first time we have came cross an issue like this in BluetoothDiscovery. We would like to look into this further.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Log in to post comments