a***@qq.com
a***@qq.com
  • 发布:2017-10-20 11:03
  • 更新:2017-10-20 11:03
  • 阅读:2000

mui蓝牙打印中文乱码求解决

分类:Native.js

mui.plusReady(function(){
var main = plus.android.runtimeMainActivity();
var BluetoothAdapter = plus.android.importClass("android.bluetooth.BluetoothAdapter");
var UUID=plus.android.importClass("java.util.UUID");
uuid=UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
var BAdapter = BluetoothAdapter.getDefaultAdapter();
BAdapter.cancelDiscovery();//停止扫描
var addres_mac = plus.storage.getItem("printer");//传入打印机mac地址
device=BAdapter.getRemoteDevice(addres_mac);
plus.android.importClass(device);
});

function print(){
bluetoothSocket = device.createInsecureRfcommSocketToServiceRecord(uuid);
plus.android.importClass(bluetoothSocket);
if(!bluetoothSocket.isConnected()){
bluetoothSocket.connect();
}
var outputStream=bluetoothSocket.getOutputStream();
plus.android.importClass(outputStream);
var string="你好123";
var bytes = plus.android.invoke(string,'getBytes','gbk');
//console.log(bytes+"."+bytes.length);
outputStream.write(bytes);
outputStream.flush();
}

2017-10-20 11:03 负责人:无 分享
已邀请:

该问题目前已经被锁定, 无法添加新回复