Android Guides | Samples

Android.Hardware.Usb.UsbManager Class

This class allows you to access the state of USB and communicate with USB devices.

See Also: UsbManager

Syntax

[Android.Runtime.Register("android/hardware/usb/UsbManager", DoNotGenerateAcw=true)]
public class UsbManager : Object

Remarks

This class allows you to access the state of USB and communicate with USB devices. Currently only host mode is supported in the public API.

You can obtain an instance of this class by calling Context.GetSystemService(String).

java Example

UsbManager manager = (UsbManager) getSystemService(Context.USB_SERVICE);

Developer Guides

For more information about communicating with USB hardware, read the USB developer guide.

[Android Documentation]

Requirements

Namespace: Android.Hardware.Usb
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 12

The members of Android.Hardware.Usb.UsbManager are listed below.

See Also: Object

Protected Constructors

A constructor used when creating managed representations of JNI objects; called by the runtime.

Public Fields

const
ActionUsbAccessoryAttachedString. Broadcast Action: A broadcast for USB accessory attached event.
const
ActionUsbAccessoryDetachedString. Broadcast Action: A broadcast for USB accessory detached event.
const
ActionUsbDeviceAttachedString. Broadcast Action: A broadcast for USB device attached event.
const
ActionUsbDeviceDetachedString. Broadcast Action: A broadcast for USB device detached event.
const
ExtraAccessoryString. Name of extra for UsbManager.ActionUsbAccessoryAttached and UsbManager.ActionUsbAccessoryDetached broadcasts containing the UsbAccessory object for the accessory.
const
ExtraDeviceString. Name of extra for UsbManager.ActionUsbDeviceAttached and UsbManager.ActionUsbDeviceDetached broadcasts containing the UsbDevice object for the device.
const
ExtraPermissionGrantedString. Name of extra added to the PendingIntent passed into UsbManager.RequestPermission(UsbDevice,PendingIntent) or UsbManager.RequestPermission(UsbAccessory,PendingIntent) containing a boolean value indicating whether the user granted permission or not.

Public Properties

[read-only]
DeviceListIDictionary<string, UsbDevice>. Returns a HashMap containing all USB devices currently attached.

Protected Properties

[read-only]
override
ThresholdClassIntPtr. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.
[read-only]
override
ThresholdTypeType. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Public Methods

GetAccessoryList() : UsbAccessory[]
Returns a list of currently attached USB accessories. (in the current implementation there can be at most one)
HasPermission(UsbAccessory) : Boolean
Returns true if the caller has permission to access the accessory.
HasPermission(UsbDevice) : Boolean
Returns true if the caller has permission to access the device.
OpenAccessory(UsbAccessory) : ParcelFileDescriptor
Opens a file descriptor for reading and writing data to the USB accessory.
OpenDevice(UsbDevice) : UsbDeviceConnection
Opens the device so it can be used to send and receive data using UsbRequest.
RequestPermission(UsbAccessory, PendingIntent)
Requests temporary permission for the given package to access the accessory.
RequestPermission(UsbDevice, PendingIntent)
Requests temporary permission for the given package to access the device.