要获得蓝牙设备,您必须获取BluetoothAdapter的实例并调用该startDiscovery()方法.您还需要注册ACTION_FOUND意图.它可以这样做:
private BroadcastReceiver mBlueToothInfoDiscoveryListener = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent)
{
String action = intent.getAction();
if (BluetoothDevice.ACTION_FOUND.equals(action))
{
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
}
}
Run Code Online (Sandbox Code Playgroud)
要获取有关找到的设备的信息,您可以使用getAddress()方法.
| 归档时间: |
|
| 查看次数: |
795 次 |
| 最近记录: |