首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Brother SDK调用PrintImage导致应用程序出现JNI检测错误: GetStringUTFChars接收到空jstring

Brother SDK调用PrintImage导致应用程序出现JNI检测错误: GetStringUTFChars接收到空jstring
EN

Stack Overflow用户
提问于 2020-02-13 11:48:42
回答 2查看 318关注 0票数 3

当前正在为标签打印机使用Brother SDK,当我调用资产管理器时,位图出现,但当它被解析为打印图像时,它崩溃了。

代码语言:javascript
复制
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.

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2020-03-28 12:43:30

我也有这个问题。您是否确保授予了android.permission.WRITE_EXTERNAL_STORAGE权限。在清单文件中包含这个是不够的,但是通过请求用户的许可,这个特定的错误就消失了。

Credit to this post on SO

票数 0
EN

Stack Overflow用户

发布于 2020-05-15 19:53:13

对于任何被卡住的人来说,即使他们被授予了写权限,这也是关于b-PAC试图创建的工作路径。

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

只需在PrinterInfo对象中定义自己的路径即可。按如下方式设置workPath变量:

代码语言:javascript
复制
PrinterInfo mPrintSettings = mPrinter.getPrinterInfo();
mPrintSettings.workPath = "your/custom/work/path";

它在文档中说,如果你这样做,你甚至不需要权限。但不管怎样我还是要留着它。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60200186

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档