Zebra Android SDK printer not printing with android 11: bluetooth light is flashing but not printing

// Expert user has replied.
Y Yanis Dalabiras 3 years 4 months ago
144 1 0

We have an android app in order to print images using the android sdk for zebra (ZSDK_ANDROID_API.jar). The printer is the ZQ320 model and is in ZPL_HYBRID mode.
The same app with the same printer in some devices doesn't work: the bluetooth light flashing but it stopping flashing and ending up not printing anything meanwhile in other devices prints okey.
We are trying finding out if any exception is thrown but it seems no exception throws in all code as far as we know.
One of the devices that produces the issue has the following OS data:
Model: SAMSUNG S-10.
Android version: 11
knox VERSION: knox API LEVEL 33.
UI version: 3.1
Please could anyone give us a clue or some strategy to debug the problem?
Thanks in advance.
public static void printBitmapZebra(ZebraPrinter printer, Bitmap path) throws ConnectionException {
String setSizeCommand = "^XA^LL" + path.getHeight() + "^XZ";
// Sets size.
printer.sendCommand(setSizeCommand);
ZebraImageAndroid oZebraImage = new ZebraImageAndroid(path);
printer.printImage(
oZebraImage, 0, 0,
path.getWidth(),
path.getHeight(), false);
}
And previous method is invoked from this from UI:
public void onClickPrint(View view) {
new Thread(() -> {
Connection connection = null;
try {
String mac = macAddress.getText().toString();
if (isNullOrEmpty(mac)) {
runOnUiThread(() -> UIHelper.showCustomToast(
this,
"Debe de especificar una dirección para la impresora."));
return;
}
showModalLoadingDialog("Impresión", "Generando imagen");
Bitmap bm = BitmapUtils.getBitmapFromWebview(oWebViewBmpGenerator);
BitmapUtils.saveBitmapToTempFolder(this,bm);
bm = BitmapUtils.toGrayScale(bm);
bm = BitmapUtils.getScaledPrinterBitmap(bm, 203); // 203 -> ZEBRA ZQ320
if (bm == null) {
throw new Exception("No se generó una imagen para imprimir.");
}
updateLoadingDialog( "Conectando con la impresora");
SettingsHelper.saveBluetoothAddress(PrintZebraActivity.this, mac);
connection = new BluetoothConnection(macAddress.getText().toString());
connection.open();
ZebraPrintUtils.setStatus(connection);
ZebraPrinter printer = ZebraPrinterFactory.getInstance(connection);
updateLoadingDialog("Enviando imagen");
ZebraPrintUtils.printBitmapZebra(printer, bm);
connection.close();
connection = null;
} catch (Exception e) {
cclsLog.log(this, e);
UIHelper.showWarning(this, e);
} finally {
dismissModalProgressDialog();
if (connection != null) {
try {
connection.close();
} catch (Exception ignored) {
}
}
}
}).start();
}

Please Register or Login to post a reply

1 Replies

S Steven Si

Does this problem only happen on Android devices that run Android 11? To use Bluetooth on Android 10 and above, we need to add ACCESS_FINE_LOCATION. Make sure that the FINE location permission is in the manifest file. Let us know if this solves the issue.

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