如何获取正在使用的蓝牙名称?

现在我的手机连接了两个蓝牙耳机,其中一个正在使用中,另一个正处于连接状态。如何获取正在使用的蓝牙耳机的名称?目前,我已经知道如何获得蓝牙耳机的名称,但我无法得到哪一个正在使用。有没有可用的接口?

// 这时获取所有蓝牙设备的方法
mAdapter = BluetoothAdapter.getDefaultAdapter();
mAdapter.getProfileProxy(ctx, new BluetoothProfile.ServiceListener() {

            @Override
            public void onServiceDisconnected(int profile) {
                LogUtil.e(TAG, "onServiceDisconnected");
                callback.onFail();
            }

            @Override
            public void onServiceConnected(int profile, BluetoothProfile proxy) {
                LogUtil.e(TAG, "onServiceConnected");
                List<BluetoothDevice> mDevices = proxy.getConnectedDevices();
                if (mDevices != null && mDevices.size() > 0) {
                    LogUtil.e(TAG, "connected devices not null");
                    for (BluetoothDevice device : mDevices) {
                        if (device != null) {
                            mDeviceName = device.getName();
                            callback.onSuccess(mDeviceName);
                        }
                    }
                }
                callback.onFail();
            }
        }, mProfileType);
阅读 5.5k
2 个回答

BluetoothAdapter.getDefaultAdapter()

我感觉默认的应该就是

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题