var mScanCallback = plus.android.implements("android.bluetooth.BluetoothAdapter$LeScanCallback", {
"onLeScan": function(device, rssi, scanRecord) {
if(device != null) {
$('.list').css('display','flex');
console.log("mScanCallback");
/*var BluetoothDevice = plus.android.importClass("android.bluetooth.BluetoothDevice");
device = new BluetoothDevice();*/
var li = document.createElement('li');
li.setAttribute('class', 'list_item');
var p1 = document.createElement("span");
p1.appendChild(document.createTextNode('名称:' + device.getName()));
var p2 = document.createElement("span");
p2.appendChild(document.createTextNode('地址:' + device.getAddress()));
var p3 = document.createElement("span");
p3.appendChild(document.createTextNode('信号:' + rssi));
li.appendChild(p1);
li.appendChild(p2);
li.appendChild(p3);
deviceList.appendChild(li);
}
}
});
直接使用device.getName() 会报错,方法未定义。
0 个回复