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();
}
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.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.