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
- 阅读:28942
50 个评论
要回复文章请先登录或注册
huyong1978
Jayming1024 (作者)
Jayming1024 (作者)
Jayming1024 (作者)
huyong1978
Jayming1024 (作者)
问天玄铁
Jayming1024 (作者)
Jayming1024 (作者)
蔡繁荣