简体   繁体   English

JavaPOS 无法声明设备

[英]JavaPOS can't claim device

I'm developing an application which implements JavaPOS.我正在开发一个实现 JavaPOS 的应用程序。 I have configured the setting correctly but I still not able to print the receipt.我已正确配置设置,但仍然无法打印收据。 (I can make a print from CITIZEN JavaPOS TEST PRO Ver.1.3.4 but not from my program) (我可以从 CITIZEN JavaPOS TEST PRO Ver.1.3.4 打印,但不能从我的程序打印)

Here is some part of my code:这是我的代码的一部分:

import jpos.*;
import jpos.util.JposPropertiesConst;

... ...

System.setProperty(JposPropertiesConst.JPOS_POPULATOR_FILE_PROP_NAME,"C:\\path_to_config\\jpos.xml");

... ...

POSPrinter printer = new POSPrinter();
try {
  printer.open("CITIZEN S310II USB Windows");
  printer.claim(100);
  printer.setDeviceEnabled(true);
  printer.setMapMode(POSPrinterConst.PTR_MM_METRIC);

  printer.transactionPrint(POSPrinterConst.PTR_S_RECEIPT, POSPrinterConst.PTR_TP_TRANSACTION);

  String LF     = ((char) 0x0a) + "";
  printer.printNormal(POSPrinterConst.PTR_S_RECEIPT, "TEST" + LF + LF + LF);
  printer.cutPaper(100);
} catch (Exception e) {
  e.printStackTrace();
} finally {
  try {
    printer.setDeviceEnabled(false);
    printer.release();
    printer.close();
  } catch (Exception e) {
    e.printStackTrace();
  }
}

.... ....

The error occurred when I tried to call printer.claim(1000);当我尝试调用 printer.claim(1000); 时发生错误; stating陈述

jpos.JposException: CSJjposCom access error.
    at com.citizen.jpos.b.e.d(Unknown Source)
    at com.citizen.jpos.b.e.claim(Unknown Source)
    at jpos.BaseJposControl.claim(Unknown Source)
    at simplepos.billUI.printBill(billUI.java)
    ....

My library are:我的图书馆是:

./CBMjpos.jar
./lib/comm.jar
./lib/jna.jar
./lib/xerces-2.6.0.jar
./lib/xerces2.jar
./lib/

Please help, I can't find any resource to fix this problem请帮忙,我找不到任何资源来解决这个问题

It is occurred because of special permission needed.这是由于需要特殊许可而发生的。

Add this in manifest file and try.将此添加到清单文件中并尝试。 Help for me.帮我。

<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM