Added in API level 12

UsbAccessory


open class UsbAccessory : Parcelable
kotlin.Any
   ↳ android.hardware.usb.UsbAccessory

A class representing a USB accessory, which is an external hardware component that communicates with an android application over USB. The accessory is the USB host and android the device side of the USB connection.

When the accessory connects, it reports its manufacturer and model names, the version of the accessory, and a user visible description of the accessory to the device. The manufacturer, model and version strings are used by the USB Manager to choose an appropriate application for the accessory. The accessory may optionally provide a unique serial number and a URL to for the accessory's website to the device as well.

An instance of this class is sent to the application via the UsbManager.ACTION_USB_ACCESSORY_ATTACHED Intent. The application can then call UsbManager.openAccessory to open a file descriptor for reading and writing data to and from the accessory.

Summary

Inherited constants
Public methods
open Int

open Boolean
equals(other: Any?)

Indicates whether some other object is "equal to" this one.

open String?

Returns a user visible description of the accessory.

open String

Returns the manufacturer name of the accessory.

open String

Returns the model name of the accessory.

open String?

Returns the unique serial number for the accessory.

open String?

Returns the URI for the accessory.

open String?

Returns the version of the accessory.

open Int

open String

open Unit
writeToParcel(parcel: Parcel, flags: Int)

Properties
static Parcelable.Creator<UsbAccessory!>

Public methods

describeContents

Added in API level 12
open fun describeContents(): Int
Return
Int a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or android.os.Parcelable#CONTENTS_FILE_DESCRIPTOR

equals

Added in API level 12
open fun equals(other: Any?): Boolean

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj This value may be null.
Return
Boolean true if this object is the same as the obj argument; false otherwise.

getDescription

Added in API level 12
open fun getDescription(): String?

Returns a user visible description of the accessory.

Return
String? the accessory description, or null if not set

getManufacturer

Added in API level 12
open fun getManufacturer(): String

Returns the manufacturer name of the accessory.

Return
String the accessory manufacturer This value cannot be null.

getModel

Added in API level 12
open fun getModel(): String

Returns the model name of the accessory.

Return
String the accessory model This value cannot be null.

getSerial

Added in API level 12
open fun getSerial(): String?

Returns the unique serial number for the accessory. This is an optional serial number that can be used to differentiate between individual accessories of the same model and manufacturer

Return
String? the unique serial number, or null if not set
Exceptions
java.lang.SecurityException if the app targets SDK >= {@value android.os.Build.VERSION_CODES#Q} and the app does not have permission to read from the accessory.

getUri

Added in API level 12
open fun getUri(): String?

Returns the URI for the accessory. This is an optional URI that might show information about the accessory or provide the option to download an application for the accessory

Return
String? the accessory URI, or null if not set

getVersion

Added in API level 12
open fun getVersion(): String?

Returns the version of the accessory.

Return
String? the accessory version, or null if not set

hashCode

Added in API level 12
open fun hashCode(): Int
Return
Int a hash code value for this object.

toString

Added in API level 12
open fun toString(): String
Return
String a string representation of the object.

writeToParcel

Added in API level 12
open fun writeToParcel(
    parcel: Parcel,
    flags: Int
): Unit
Parameters
dest The Parcel in which the object should be written. This value cannot be null.
flags Int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE. Value is either 0 or a combination of android.os.Parcelable#PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES

Properties

CREATOR

Added in API level 12
static val CREATOR: Parcelable.Creator<UsbAccessory!>