Reputation: 2897
I want to detect whether my android smart phone supports USB On-The-Go . I have searched a lot in the internet but could not find any way to do that !
I have found that there is an application "USB OTG Checker" . Here is some screenshot of that app .
How can I check whether an USB is plugged in smartphone ?
Upvotes: 3
Views: 3215
Reputation: 4232
your answer is here : https://stackoverflow.com/a/34691806/3818437
add a <uses-feature>
element to your manifest
, indicating that you are interested in the android.hardware.usb.host
feature.
OR use 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).
Upvotes: 1
Reputation: 1145
Actually USB Host actually similar with OTG,since we can check the USB Host feature programically, here are my solution,hope this help you.
/**
* Check the device whether has USB-HOST feature.
*/
public static boolean hasUsbHostFeature(Context context) {
return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_USB_HOST);
}
Upvotes: 2