[英]How to check whether Android device supports OTG features programatically
I want to check whether a device supports OTG features programatically . 我想以编程方式检查设备是否支持OTG功能。 I have tried a lot about this in Internet but could not find any thing .
我在互联网上尝试过很多但是找不到任何东西。
How can I do that ? 我怎样才能做到这一点 ?
thnx to @CommonsWare: How to detect if Android has full USB support or not? thnx到@CommonsWare: 如何检测Android是否有完整的USB支持?
The official way to determine if the device has USB host capability is to use the associated system feature. 确定设备是否具有USB主机功能的官方方法是使用相关的系统功能。
Ideally, add a <uses-feature>
element to your manifest, indicating that you are interested in the android.hardware.usb.host
feature. 理想情况下,在清单中添加
<uses-feature>
元素,表明您对android.hardware.usb.host
功能感兴趣。
OR use PackageManager.hasSystemFeature(), and FEATURE_USB_HOST
. 或者使用
PackageManager.hasSystemFeature(), and FEATURE_USB_HOST
。
FEATURE_USB_HOST
is defined as the same string as you would be using in <uses-feature> (android.hardware.usb.host)
. FEATURE_USB_HOST
定义为与<uses-feature> (android.hardware.usb.host)
字符串相同的字符串。
in code words: 用代码字:
context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_USB_HOST);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.