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();
}
Jayming1024
- 发布:2015-08-04 14:49
- 更新:2020-08-31 17:13
- 阅读:28946
50 个评论
要回复文章请先登录或注册
haapy
kunlunan
5***@qq.com
小权
1***@qq.com
2***@qq.com
1***@qq.com
2***@qq.com
9***@qq.com
4***@qq.com