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 |
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 |
getModel() Returns the model name of the accessory. |
open String? |
Returns the unique serial number for the accessory. |
open String? |
getUri() Returns the URI for the accessory. |
open String? |
Returns the version of the accessory. |
open Int |
hashCode() |
open String |
toString() |
open Unit |
writeToParcel(parcel: Parcel, flags: Int) |
Properties | |
---|---|
static Parcelable.Creator<UsbAccessory!> |
Public methods
describeContents
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
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 returntrue
. - It is symmetric: for any non-null reference values
x
andy
,x.equals(y)
should returntrue
if and only ify.equals(x)
returnstrue
. - It is transitive: for any non-null reference values
x
,y
, andz
, ifx.equals(y)
returnstrue
andy.equals(z)
returnstrue
, thenx.equals(z)
should returntrue
. - It is consistent: for any non-null reference values
x
andy
, multiple invocations ofx.equals(y)
consistently returntrue
or consistently returnfalse
, provided no information used inequals
comparisons on the objects is modified. - For any non-null reference value
x
,x.equals(null)
should returnfalse
.
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
open fun getDescription(): String?
Returns a user visible description of the accessory.
Return | |
---|---|
String? |
the accessory description, or null if not set |
getManufacturer
open fun getManufacturer(): String
Returns the manufacturer name of the accessory.
Return | |
---|---|
String |
the accessory manufacturer This value cannot be null . |
getModel
open fun getModel(): String
Returns the model name of the accessory.
Return | |
---|---|
String |
the accessory model This value cannot be null . |
getSerial
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
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
open fun getVersion(): String?
Returns the version of the accessory.
Return | |
---|---|
String? |
the accessory version, or null if not set |
hashCode
open fun hashCode(): Int
Return | |
---|---|
Int |
a hash code value for this object. |
toString
open fun toString(): String
Return | |
---|---|
String |
a string representation of the object. |
writeToParcel
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 |