1

我正在尝试使用 USB 接口从我的 cordova 应用程序打印到 bixolon srp-350iii 热敏打印机。

我的 BixolonPrint.java 包括以下内容:

case BixolonPrinter.MESSAGE_USB_DEVICE_SET:
Log.d(TAG, "perform mHandler: MESSAGE_USB_DEVICE_SET");
if (msg.obj == null) {
    BixolonPrint.this.cbContext.error("USB printer not found");

} else {
    //connect printer

}

这是我的 index.html

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *; img-src 'self' data: content:;">
        <meta name="format-detection" content="telephone=no">
        <meta name="msapplication-tap-highlight" content="no">
        <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
        <link rel="stylesheet" type="text/css" href="css/index.css">
        <title>Bixolon Test</title>

          <link rel="stylesheet" href="css/bootstrap.min.css">
          <script src="js/jquery.min.js"></script>
          <script src="js/bootstrap.min.js"></script>

    </head>
    <body>

        <div class="container">

        <h2>Bixolon Test</h2>
        <button type="button" class="btn btn-default btn-lg btn-block" onclick="PrintThisData(this, 'red')">CLICK TO TEST PRINT</button>
        <script>
        function PrintThisData(elmnt,clr) {
            elmnt.style.color = clr;

            // compose text
            cordova.plugins.bixolonPrint.addLine({
                text: "This is a test message. Jing Yeng\r\n",
                textAlign: cordova.plugins.bixolonPrint.TextAlign.CENTER,
                fontStyle: cordova.plugins.bixolonPrint.FontStyle.BOLD
            });
            cordova.plugins.bixolonPrint.addHr();
            cordova.plugins.bixolonPrint.addLine("#@*èòçìàé€");
            // finally print
            cordova.plugins.bixolonPrint.printText(
                function (response) {
                    alert("Ticket printed successfully. Press OK to proceed!")
                },
                function (error) {
                    alert("Failed: " + error)
                },
                {
                    codePage: cordova.plugins.bixolonPrint.CodePage.CP_1252_LATIN1
                }
            );
        }
        </script>


        </div>

        <script type="text/javascript" src="cordova.js"></script>
        <script type="text/javascript" src="js/index.js"></script>
    </body>
</html>

在我的设备上安装生成的 apk 后,我无法从运行 android 4.4 的 android 设备上检测到打印机。打印机已使用 USB 连接到 android 设备。

这可能是什么问题?

4

0 回答 0