3

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 .

How can I do that ?

4

1 回答 1

6

thnx to @CommonsWare:如何检测 Android 是否完全支持 USB?

确定设备是否具有 USB 主机功能的官方方法是使用相关的系统功能。

理想情况下,<uses-feature>向您的清单添加一个元素,表明您对该android.hardware.usb.host功能感兴趣。

使用PackageManager.hasSystemFeature(), and FEATURE_USB_HOST.

FEATURE_USB_HOST被定义为与您在 in 中使用的字符串相同的字符串<uses-feature> (android.hardware.usb.host)

用暗语:

context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_USB_HOST);
于 2016-01-09T09:28:22.847 回答