public class UsbAccessory extends Object implements Parcelable
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(android.hardware.usb.UsbAccessory)
to open a file descriptor
for reading and writing data to and from the accessory.
For more information about communicating with USB hardware, read the USB developer guide.
Parcelable.ClassLoaderCreator<T>, Parcelable.Creator<T>
Modifier and Type | Field and Description |
---|---|
static Parcelable.Creator<UsbAccessory> |
CREATOR |
static int |
DESCRIPTION_STRING |
static int |
MANUFACTURER_STRING |
static int |
MODEL_STRING |
static int |
SERIAL_STRING |
static int |
URI_STRING |
static int |
VERSION_STRING |
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE
Constructor and Description |
---|
UsbAccessory(String[] strings)
UsbAccessory should only be instantiated by UsbService implementation
|
UsbAccessory(String manufacturer,
String model,
String description,
String version,
String uri,
String serial)
UsbAccessory should only be instantiated by UsbService implementation
|
Modifier and Type | Method and Description |
---|---|
int |
describeContents()
Describe the kinds of special objects contained in this Parcelable's
marshalled representation.
|
boolean |
equals(Object obj)
Compares this instance with the specified object and indicates if they
are equal.
|
String |
getDescription()
Returns a user visible description of the accessory.
|
String |
getManufacturer()
Returns the manufacturer name of the accessory.
|
String |
getModel()
Returns the model name of the accessory.
|
String |
getSerial()
Returns the unique serial number for the accessory.
|
String |
getUri()
Returns the URI for the accessory.
|
String |
getVersion()
Returns the version of the accessory.
|
int |
hashCode()
Returns an integer hash code for this object.
|
String |
toString()
Returns a string containing a concise, human-readable description of this
object.
|
void |
writeToParcel(Parcel parcel,
int flags)
Flatten this object in to a Parcel.
|
public static final int MANUFACTURER_STRING
public static final int MODEL_STRING
public static final int DESCRIPTION_STRING
public static final int VERSION_STRING
public static final int URI_STRING
public static final int SERIAL_STRING
public static final Parcelable.Creator<UsbAccessory> CREATOR
public UsbAccessory(String manufacturer, String model, String description, String version, String uri, String serial)
public UsbAccessory(String[] strings)
public String getManufacturer()
public String getModel()
public String getDescription()
public String getVersion()
public String getUri()
public String getSerial()
public boolean equals(Object obj)
Object
o
must represent the same object
as this instance using a class-specific comparison. The general contract
is that this comparison should be reflexive, symmetric, and transitive.
Also, no object reference other than null is equal to null.
The default implementation returns true
only if this ==
o
. See Writing a correct
equals
method
if you intend implementing your own equals
method.
The general contract for the equals
and Object.hashCode()
methods is that if equals
returns true
for
any two objects, then hashCode()
must return the same value for
these objects. This means that subclasses of Object
usually
override either both methods or neither of them.
equals
in class Object
obj
- the object to compare this instance with.true
if the specified object is equal to this Object
; false
otherwise.Object.hashCode()
public int hashCode()
Object
Object.equals(java.lang.Object)
returns true
must return
the same hash code value. This means that subclasses of Object
usually override both methods or neither method.
Note that hash values must not change over time unless information used in equals comparisons also changes.
See Writing a correct
hashCode
method
if you intend implementing your own hashCode
method.
hashCode
in class Object
Object.equals(java.lang.Object)
public String toString()
Object
getClass().getName() + '@' + Integer.toHexString(hashCode())
See Writing a useful
toString
method
if you intend implementing your own toString
method.
public int describeContents()
Parcelable
describeContents
in interface Parcelable
public void writeToParcel(Parcel parcel, int flags)
Parcelable
writeToParcel
in interface Parcelable
parcel
- The Parcel in which the object should be written.flags
- Additional flags about how the object should be written.
May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE
.