当前连接的蓝牙设备android [英] Currently connected bluetooth device android

查看:446
本文介绍了当前连接的蓝牙设备android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在Android的蓝牙设备中看到两种状态. 1.配对 2.已连接. -
我正在尝试获取Android中当前连接的蓝牙设备.但是我从adapter.getBondedDevices();仅获得配对的设备列表,我需要当前已连接的设备.我怎么能得到这个.请有人帮助我实现这一目标.预先感谢.

I can able to see two states in Bluetooth device in Android. 1. Paired 2. Connected. -
I am trying to get currently connected Bluetooth device in Android. But I am getting only paired device list from adapter.getBondedDevices(); I need currently connected device. How can i get this. Please someone help me to achieve this. Thanks in advance.

推荐答案

这很简单. Android BluetoothManager 具有

That's pretty straight forward. Android BluetoothManager have method of

getConnectedDevices()

getConnectedDevices()

实施方式:

BluetoothManager manager = (BluetoothManager) getSystemService(BLUETOOTH_SERVICE);
    List<BluetoothDevice> connected = manager.getConnectedDevices(GATT);
    Log.i("Connected Devices: ", connected.size()+"");

如果您想了解有关已连接设备的更多详细信息,则可以使用上述列表方法将其放入for循环中,并获取所连接的每个蓝牙设备的内部详细信息.

If you want more details about connected devices then you can use the above list method put it into for loop and get the inner details of each Bluetooth device which are connected.

日志:

12-20 18:04:09.679 14933-14933/com.salman.dleague.blescanning I/Connected Devices:: 2

希望它会有所帮助:)

这篇关于当前连接的蓝牙设备android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆