android - 如何在android范围内扫描可用的蓝牙设备?

标签 android bluetooth scanning

我需要使用 google android 2.1 获取该地区可用蓝牙设备的列表。

问题是,我不仅需要这些设备的列表,我还需要找到每个设备的唯一 ID,并且我需要一个指示器,即接收到的信号有多“好”(如 android. wifi.ScanResult)...我该怎么做?

最佳答案

查看以下代码:

开始搜索

mBluetoothAdapter.startDiscovery(); 
mReceiver = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
    String action = intent.getAction();

    //Finding devices                 
    if (BluetoothDevice.ACTION_FOUND.equals(action)) 
    {
        // Get the BluetoothDevice object from the Intent
        BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
        // Add the name and address to an array adapter to show in a ListView
       mArrayAdapter.add(device.getName() + "\n" + device.getAddress());
    }
  }
};

IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND); 
registerReceiver(mReceiver, filter);

关于android - 如何在android范围内扫描可用的蓝牙设备?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3170805/

相关文章:

iphone - iOS 上的蓝牙 A2DP API 支持吗?

C++ 从 hBitmap 获取 RGB

android - 使用 PhoneGap 在 HTML 中显示联系人图像

android - Android-Java 通信的 StreamCorruptedException

javascript - 为什么上传明显成功时上传的音频会损坏?

c - 如何在 Linux x86 上使用 C 语言对蓝牙 LE 设备进行编程?

android - 从嵌入式 Android WebView 记录 HTTP 请求的开始和完成

bluetooth - 如何使用基于HM-10蓝牙模块的BLE Shield?

c# - 使用 WIA 自动化扫描多页

vb.net - 使用 WIA 和 VB 从同一台计算机上的多个扫描仪自动扫描