简体   繁体   English

如何以编程方式检查Android设备是否支持OTG功能

[英]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.

相关问题 如何检测我的android设备是否支持android中的otg电缆 - How to detect whether my android device supports otg cable in android 如何以编程方式检查android设备是否支持DLNA - How to check whether an android device supports DLNA or not programmatically 如何检查特定设备是否支持Android中的4G网络? - How to check whether a particular device supports 4G networks in Android? 如何查看Android手机是否支持TEE? - How to check whether Android phone supports TEE? 如何检查android设备是否支持用于camera2或cameraX视频稳定的OIS或EIS - How to check whether android device supports OIS or EIS for camera2 or cameraX video stabilization 以编程方式检查我的 android 设备是否已激活工作资料? - Programatically Check whether my android device has activated work profile or not? 如何检查设备是否支持用户的联系人? - How to check whether a device supports User's Contacts or not? android如何检查设备是否支持Sview - android how to check if device supports Sview 如何检测Android设备是否支持谷歌地图API - How to detect an android device whether it supports google maps API 如何检查Android MediaCodec是否支持恒定质量模式 - How to check whether Android MediaCodec supports Constant Quality mode
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM