I am trying following code to find bluetooth printers. The code runs fine on API 4 however it does not run on API 6. It starts looking for the bluetooth printers but did not go to any callbacks or neither throw any error. I am using ZSDK_API 2.9.2275.jar. Please let me know what I am doing wrong. Thanks in advance.
private void lookForPrinters() {
@Override
public void run() {
try {
BluetoothDiscoverer.findPrinters(MainActivity.this, new DiscoveryHandler() {
@Override
public void foundPrinter(DiscoveredPrinter discoveredPrinter) {
DiscoveredPrinterBluetooth discoveredPrinterBluetooth = (DiscoveredPrinterBluetooth) discoveredPrinter;
if (discoveredPrinterBluetooth.friendlyName != null && discoveredPrinterBluetooth.friendlyName.startsWith("XXXX")) { Log.i(TAG, "Discovered a printer" + discoveredPrinterBluetooth.friendlyName);
}
}
@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 , e.getMessage());
}
}
});
}
BluetoothDiscoverer.findPrinters() does go to call back. |
4 Replies
Thanks. I checked iMZ320 specification. It is not Bluetooth low energy device however I tried with com.zebra.sdk.btleComm.BluetoothLeDiscoverer but no success. In communication and interface capability it say android android 2.0 , 4.0 , 4.1. Does it mean it does not support after 4.1.
Hi Richard,
Thanks for your reply. I am already using following permission. Today I updated API to 2.11.2800. It starts going on callbacks but only go to discoveryFinished callback. It does not find Bluetooth printer. Again it is running fine on older version. The printer I am using is iMZ320.
Thanks
Maybe this helps:
Richard.
Hello.
Please google "android 6 bluetooth search permission" and read the articel(s) on Stackoverflow.
You need additional permissions for device discovery.
Hope that helps,
Richard.