ZSDK BluetoothDiscoverer.findPrinters() is not able detect Zebra ZQ310 printer

// Expert user has replied.
F Faiz Waghoo 2 years 3 months ago
373 2 0

I am trying to implement ZSDK_ANDROID_API.jar SDK for Zebra Bluetooth supported printers in my React Native app. I am referring to Zebra's blog for the same - https://developer.zebra.com/blog/develop-react-native-printing-app-andr…
In my freshly created React Native app, I'm able to print receipt by hard coding the printer's Bluetooth address however the findPrinters() API is not able to detect the printer.

But Zebra's own React Native sample app (https://github.com/ZebraDevs/Zebra-Printer-Samples/tree/ZSDKRCTDevDemo) works and the same code doesn't work for my app.
In my app, I never receive callback in foundPrinter() and only in discoveryFinished() whereas in Zebra's sample app, I receive callback in foundPrinter() before getting callback in discoveryFinished().

I don't understand what I am doing wrong since I have copied code from Zebra's sample app itself. Has anyone faced this issue?

Please register or login to post a reply

2 Replies

S Steven Si

This sounds a permission issue. First of all, please add the following permissions in the manifest file. Please note that the ACCESS_FINE_LOCATION is required for the Bluetooth discovery on newer Android OS.

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

If running on Android 11 or later, secondly, the app also needs to ask the user explicitly for the permission. See this article for details: Link-OS SDK for Android | Permissions and Bluetooth API, which has the details about the permission requirement for Bluetooth.

F Faiz Waghoo

Thank you for your reply.

It was indeed a permission issue, the ACCESS_FINE_LOCATION at that. I mean I had that permission in my manifest but I wasn't asking for that permission at run time.

But one weird thing is that, Zebra's React Native app also doesn't ask for that permission at runtime. And when I went to app info, I saw that it already had that permission along with phone and storage. I'm testing this on Android 7 so ideally it shouldn't have that permission without user's consent since dynamic permissions were added from Android 6.

CONTACT
Can’t find what you’re looking for?