3

Currently working with the Brother SDK for a label Printer and when I call Asset Manager, the Bitmap appears but when it is parsed to print image it crashes.

if (myPrinter.startCommunication()) {
AssetManager assetManager = getAssets();
          Bitmap bitmap = null;
          try{
              bitmap = BitmapFactory.decodeStream(new BufferedInputStream(assetManager.open("meme.bmp")));
             }catch(Exception e){
               e.printStackTrace();
             }
          PrinterStatus result = myPrinter.printImage(bitmap);
       if (result.errorCode != ErrorCode.ERROR_NONE) {
         Log.d("TAG", "ERROR - " + result.errorCode);
       }
         myPrinter.endCommunication();
}

Stack Readout

Debugger printout, with Image Preview.

Felix Hu
  • 33
  • 3

2 Answers2

1

For anyone got stuck even if they made sure they have the write permission granted, it was about the working path b-PAC trying to create.

The default path is: /storage/emulated/0/com.brother.ptouch.sdk/template

Just define your own path in PrinterInfo object. Set the workPath variable as such:

PrinterInfo mPrintSettings = mPrinter.getPrinterInfo();
mPrintSettings.workPath = "your/custom/work/path";

It says in the document that you don't even need the permission if you do so. But I'm going to keep it anyway.

Emre Can Serteli
  • 389
  • 1
  • 7
  • 17
  • 1
    This is awesome! Fixed our issue with our Brother printer not working with Android 10. Once I passed in a `workPath`, it started working again. Thanks so much! – Jarod Legault Dec 01 '20 at 18:26
0

I had this issue as well. Have you made sure that the android.permission.WRITE_EXTERNAL_STORAGE permisson is granted. Having this in the manifest file wasn't enough, but by requesting permisson from the user, this specific error went away.

Credit to this post on SO

matty0005
  • 26
  • 3