我正在尝试使用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设备。
这可能是什么问题?