我是安卓新手。我正在尝试扫描其他蓝牙设备。请指导我并帮助我找到解决方案。这是代码的一部分:
scan_btn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
mBluetoothAdapter.startDiscovery();
mReceiver = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (BluetoothDevice.ACTION_FOUND.equals(action)) {
BluetoothDevice device = Untent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
mArrayAdapter.add(device.getName() + "\n" + device.getAddress());
}
}
};
IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
registerReceiver(mReceiver, filter);
}
});
@Override
protected void onDestroy() {
super.onDestroy();
unregisterReceiver(mReceiver);//unregister the receiver
}