gpt4 book ai didi

java - Brother SDK调用PrintImage导致JNI DETECTED ERROR IN APPLICATION : GetStringUTFChars received NULL jstring

转载 作者:行者123 更新时间:2023-12-04 17:30:32 33 4
gpt4 key购买 nike

目前正在为标签打印机使用 Brother SDK,当我调用 Asset Manager 时,会出现位图,但当它被解析为打印图像时它崩溃了。

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.

最佳答案

对于任何人来说,即使他们确保他们获得了写入权限也会被卡住,这与 b-PAC 试图创建的工作路径有关。

默认路径为:/storage/emulated/0/com.brother.ptouch.sdk/template

只需在PrinterInfo 对象中定义您自己的路径。设置 workPath 变量:

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

它在文档中说,如果你这样做,你甚至不需要许可。但无论如何我都会保留它。

关于java - Brother SDK调用PrintImage导致JNI DETECTED ERROR IN APPLICATION : GetStringUTFChars received NULL jstring,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60200186/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com