我有带集成热敏打印机的 MobiWire MobiPrint 3 设备 (Android 4.2.2),我正在尝试在 Android Studio 中制作一个简单的应用程序以在该打印机上打印一些东西。
有人有此设备的 API 文档吗?尝试联系 Mobiwire 但没有帮助..
在 Android 4.2.2、ESC/POS 上打印的最佳方式是什么?我必须只打印文本(发票)。
谢谢。
最佳答案
试试这个:
AndroidManifest.xml
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
在Activity或Fragment中调用此函数
fun print() {
if (printer.printerStatus == Printer.PRINTER_STATUS_OK) {
val printer = Printer.getInstance()
printer.printText("Some Text")
printer.printText("Another Text")
printer.printText("Add as many Texts")
// And finally add this line
printer.printEndLine()
} else {
println("_print::(printerStatus:${status(printer.printerStatus)})")
}
}
private fun status(s: Int) = when (s) {
Printer.PRINTER_STATUS_OK -> "Printer Ok"
Printer.PRINTER_ERROR -> "Error printing, try again"
Printer.PRINTER_NO_PAPER -> "Not paper, insert paper and try again"
Printer.PRINTER_STATUS_GET_FAILED -> "Printer not working correctly"
Printer.PRINTER_STATUS_OVER_HEAT -> "Printer overheated, wait for it to cool"
else -> "No printer found on this device"
}
关于android - 如何在 MobiWire MobiPrint 3 (Android) 上打印,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53501956/