android智能终端SDK

移动支付产品接入文档


方式一

<p>开发工具:</p> <p>[HBudiler](<a href="https://dcloud.io/runtime.html#toDownload">https://dcloud.io/runtime.html#toDownload</a> &quot;HBudiler&quot;)</p> <p><img src="http://doc.szzkc.com/Public/Uploads/2018-03-08/5aa10a3b30bc9.png" alt="" /> <img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=c118a20d4af4ad5904ec9c56566cdd58&amp;amp;file=file.png" alt="" /></p> <p>蓝牙打印参考: &amp; 以下代码仅供测试参考,具体打印流程请跟进实际需求调整 &amp; JS方式实现打印,操作非常简单,代码如下:</p> <pre><code> function print(mac_address) { if (!mac_address) { mui.toast('请选择蓝牙打印机'); return; } main = plus.android.runtimeMainActivity(); BluetoothAdapter = plus.android.importClass(&amp;quot;android.bluetooth.BluetoothAdapter&amp;quot;); UUID = plus.android.importClass(&amp;quot;java.util.UUID&amp;quot;); uuid = UUID.fromString(&amp;quot;00001101-0000-1000-8000-00805F9B34FB&amp;quot;); BAdapter = BluetoothAdapter.getDefaultAdapter(); device = BAdapter.getRemoteDevice(mac_address); plus.android.importClass(device); bluetoothSocket = device.createInsecureRfcommSocketToServiceRecord(uuid); plus.android.importClass(bluetoothSocket); if (!bluetoothSocket.isConnected()) { console.log('检测到设备未连接,尝试连接....'); bluetoothSocket.connect(); } console.log('设备已连接'); if (bluetoothSocket.isConnected()) { var outputStream = bluetoothSocket.getOutputStream(); plus.android.importClass(outputStream); var string = &amp;quot;打印测试\r\n&amp;quot;; var bytes = plus.android.invoke(string, 'getBytes', 'gbk'); outputStream.write(bytes); outputStream.flush(); device = null //这里关键 bluetoothSocket.close(); //必须关闭蓝牙连接否则意外断开的话打印错误 } } //页面调用 &amp;lt;input id=&amp;quot;btnPrint&amp;quot; type=&amp;quot;button&amp;quot; value=&amp;quot;打印&amp;quot; onclick=&amp;quot;print('00:11:22:33:44:55')&amp;quot; /&amp;amp;</code></pre>

页面列表

ITEM_HTML