介绍通过qt android下的QAndroidJniObject获取usb设备列表的过程
工具/原料
qt5.8
安卓下获取usb设备列表
1、在安卓下获取usb设备的列表,过程还是比较简单。这里就是依据以下代码,看在qt下如何实现这个流程
qt android下获取usb设备列表
1、(1)Context.USB_SERVICEUSB_SERVICE是android.content.Context中的静态成员变量,可以通过getStaticObjectField来获取
2、(2)getSystemService函数getSystemService 是android.app.Activity类的成员函数,其输入焊剑杂锭参数为Context.USB_SERVICE,返回的是android.hardware.usb.UsbManager的对象
3、(3)getDeviceListgetDeviceList是android.hardware.usb.UsbManager类的成员函数,获取一个java.util.HashMap类的变量
4、(4)遍历HashMap遍历列表中的usb设备