当前正在为标签打印机使用Brother SDK,当我调用资产管理器时,位图出现,但当它被解析为打印图像时,它崩溃了。
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();
}发布于 2020-03-28 12:43:30
我也有这个问题。您是否确保授予了android.permission.WRITE_EXTERNAL_STORAGE权限。在清单文件中包含这个是不够的,但是通过请求用户的许可,这个特定的错误就消失了。
发布于 2020-05-15 19:53:13
对于任何被卡住的人来说,即使他们被授予了写权限,这也是关于b-PAC试图创建的工作路径。
默认路径为:/storage/emulated/0/com.brother.ptouch.sdk/template
只需在PrinterInfo对象中定义自己的路径即可。按如下方式设置workPath变量:
PrinterInfo mPrintSettings = mPrinter.getPrinterInfo();
mPrintSettings.workPath = "your/custom/work/path";它在文档中说,如果你这样做,你甚至不需要权限。但不管怎样我还是要留着它。
https://stackoverflow.com/questions/60200186
复制相似问题