如何检查配对的蓝牙设备是打印机还是扫描仪 (Android) [英] How to Check if an Paired Bluetooth device is a Printer or a Scanner (Android)

查看:27
本文介绍了如何检查配对的蓝牙设备是打印机还是扫描仪 (Android)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

希望能帮到我,我正在开发一个 Android 应用程序,需要连接蓝牙设备,如扫描仪和打印机,目前我可以列出所有配对设备,但我想知道配对设备是否是打印机、扫描仪、移动设备等.

I hope can help me, I am developing an Android App, that require to connect with Bluetooth devices, like Scanner and Printer, currently I can list all Paired devices, but i want to know if the paired device is a Printer, Scanner, Mobile, etc.

有什么方法可以知道配对的蓝牙设备的种类吗?

There is some way to know the kind of bluetooth device paired?

推荐答案

简而言之,

是的,你可以.你可以通过使用设备的 UUID 来做到这一点.如果您知道设备的 UUID,您可以从报告的 UUID 中匹配它们,并知道配对的设备是什么.

Yes you can. You can do this by using the UUID of the device. If you know the UUID of a device you can match them up from the reported UUID and know which paired device is what.

像这样:

BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();

Method getUuidsMethod = BluetoothAdapter.class.getDeclaredMethod("getUuids", null);

ParcelUuid[] uuids = (ParcelUuid[]) getUuidsMethod.invoke(adapter, null);

现在只需将检索到的 UUID 与已知的设备 UUID(在线或包装盒上)进行比较.

Now simply compare the retrieved UUID to the devices known UUID( online or on the box).

如果它们匹配,您就知道它是什么设备.

If they are a match you know what device it is.

注意:最常见的 UUID(扫描仪、打印机、鼠标)具有通用 UUID 0001101-0000-1000-8000-00805F9B34FB

Note: most common UUID (scanners, printers, Mice) have the generic UUID 0001101-0000-1000-8000-00805F9B34FB

阅读getUUID() 方法,paracable 方法,Method java 类,最后 Java.util.UUID.

Read about the getUUID() method, paracable method , Method java class and finally Java.util.UUID.

这篇关于如何检查配对的蓝牙设备是打印机还是扫描仪 (Android)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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