我很确定至少有两个设备可以通过蓝牙解决,但我的应用程序只显示配对。我已经给了蓝牙许可,我不明白问题出在哪里。你能找到吗?
create table IF NOT EXISTS RequestTable (
rtTicketId bigserial unique not null AUTO_INCREMENT,
primary key (rtTicketId));
create table IF NOT EXISTS Vm (
vmId bigserial unique not null AUTO_INCREMENT,
primary key (vmId),
foreign key (rtTicketId) references RequestTable(rtTicketId));
create table IF NOT EXISTS Db (
dbId bigserial unique not null AUTO_INCREMENT,
rtTicketId bigserial unique not null,
primary key (dbId),
foreign key (rtTicketId) references RequestTable(rtTicketId));
答案 0 :(得分:-1)
如果我没有错,你只能获得保税装置。您的代码应该如下所示。
IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
void startScan(){
adapter.clear(); //List View cleared
deviceList = btAdapter.getBondedDevices(); //Paired Device
for (BluetoothDevice bd : deviceList) //Adding Paired Device
adapter.add(bd.getName() + "\n" + bd.getAddress()+"\t (Paired)");
//Broadcast Receiver Registration
检查蓝牙启用
(!btAdapter.isEnabled()) {
Intent BtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(BtIntent, 0);
Toast.makeText(BluetoothScannerActivity.this, "Turning on Bluetooth", Toast.LENGTH_LONG).show();
}
else{
registerReceiver(receiver,filter);
btAdapter.startDiscovery(); //Scan start
}
}
你的广播应该是方法,它的更好的parctice
receiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if(BluetoothDevice.ACTION_FOUND.equals(action)){ //Device Found
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); //Extractind Device Info
adapter.add(device.getName()+"\t"+device.getAddress()); //Adding Device to List View
}
}
};
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == BtIntent && resultCode == RESULT_OK) {
registerReceiver(receiver,filter);
btAdapter.startDiscovery();
}
}