如何检查Android设备是否以编程方式支持OTG功能 [英] How to check whether Android device supports OTG features programatically
问题描述
我想检查设备是否以编程方式支持OTG功能.我已经在Internet上对此进行了很多尝试,但是找不到任何东西.
I want to check whether a device supports OTG features programatically . I have tried a lot about this in Internet but could not find any thing .
我该怎么做?
推荐答案
thnx to @CommonsWare: How to detect if Android has full USB support or not?
确定设备是否具有USB主机功能的官方方法是使用相关的系统功能.
The official way to determine if the device has USB host capability is to use the associated system feature.
理想情况下,在清单中添加<uses-feature>
元素,表明您对android.hardware.usb.host
功能感兴趣.
Ideally, add a <uses-feature>
element to your manifest, indicating that you are interested in the android.hardware.usb.host
feature.
或使用PackageManager.hasSystemFeature(), and FEATURE_USB_HOST
.
FEATURE_USB_HOST
的定义与您在<uses-feature> (android.hardware.usb.host)
中使用的字符串相同.
FEATURE_USB_HOST
is defined as the same string as you would be using in <uses-feature> (android.hardware.usb.host)
.
用代码字表示:
context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_USB_HOST);
这篇关于如何检查Android设备是否以编程方式支持OTG功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!