如何检测我的android设备是否支持android中的otg cable

时间:2015-02-07 11:14:48

标签: android usb-drive usb-otg

我想检测我的Android智能手机是否支持USB On-The-Go。我在互联网上搜索了很多但却找不到任何办法!

我发现有一个应用程序" USB OTG Checker" 。这是该应用程序的一些截图。

enter image description here

如何检查USB是否插入智能手机?

2 个答案:

答案 0 :(得分:2)

实际上USB Host实际上与OTG类似,因为我们可以通过编程方式检查USB Host功能,这是我的解决方案,希望对您有所帮助。

    /**
 * Check the device whether has USB-HOST feature.
 */
public static boolean hasUsbHostFeature(Context context) {
    return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_USB_HOST);
}

答案 1 :(得分:1)

你的回答就在这里:https://stackoverflow.com/a/34691806/3818437

var tabledata = localStorage.getItem( "tabledata" ); $("#tabela").html( tabledata ); 添加<uses-feature>元素,表示您对manifest功能感兴趣。

使用android.hardware.usb.hostPackageManager, hasSystemFeature(), and FEATURE_USB_HOST被定义为与FEATURE_USB_HOST(android.hardware.usb.host)中使用的字符串相同的字符串。

相关问题