IT. Expert System.

Android Reference

UsbManager


android.hardware.usb

Class UsbManager



  • public class UsbManager
    extends Object
    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().

    Developer Guides

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

    • Constructor Detail

      • UsbManager

        public UsbManager(Context context,
                  IUsbManager service)
    • Method Detail

      • getDeviceList

        public HashMap<String,UsbDevice> getDeviceList()
        Returns a HashMap containing all USB devices currently attached. USB device name is the key for the returned HashMap. The result will be empty if no devices are attached, or if USB host mode is inactive or unsupported.
        Returns:
        HashMap containing all connected USB devices.
      • getAccessoryList

        public UsbAccessory[] getAccessoryList()
        Returns a list of currently attached USB accessories. (in the current implementation there can be at most one)
        Returns:
        list of USB accessories, or null if none are attached.
      • openAccessory

        public ParcelFileDescriptor openAccessory(UsbAccessory accessory)
        Opens a file descriptor for reading and writing data to the USB accessory.
        Parameters:
        accessory - the USB accessory to open
        Returns:
        file descriptor, or null if the accessor could not be opened.
      • hasPermission

        public boolean hasPermission(UsbDevice device)
        Returns true if the caller has permission to access the device. Permission might have been granted temporarily via requestPermission(UsbDevice, PendingIntent) or by the user choosing the caller as the default application for the device.
        Parameters:
        device - to check permissions for
        Returns:
        true if caller has permission
      • hasPermission

        public boolean hasPermission(UsbAccessory accessory)
        Returns true if the caller has permission to access the accessory. Permission might have been granted temporarily via requestPermission(UsbAccessory, PendingIntent) or by the user choosing the caller as the default application for the accessory.
        Parameters:
        accessory - to check permissions for
        Returns:
        true if caller has permission
      • requestPermission

        public void requestPermission(UsbDevice device,
                             PendingIntent pi)
        Requests temporary permission for the given package to access the device. This may result in a system dialog being displayed to the user if permission had not already been granted. Success or failure is returned via the PendingIntent pi. If successful, this grants the caller permission to access the device only until the device is disconnected. The following extras will be added to pi:
        Parameters:
        device - to request permissions for
        pi - PendingIntent for returning result
      • requestPermission

        public void requestPermission(UsbAccessory accessory,
                             PendingIntent pi)
        Requests temporary permission for the given package to access the accessory. This may result in a system dialog being displayed to the user if permission had not already been granted. Success or failure is returned via the PendingIntent pi. If successful, this grants the caller permission to access the accessory only until the device is disconnected. The following extras will be added to pi:
        Parameters:
        accessory - to request permissions for
        pi - PendingIntent for returning result
      • isFunctionEnabled

        public boolean isFunctionEnabled(String function)
        Returns true if the specified USB function is currently enabled.
        Parameters:
        function - name of the USB function
        Returns:
        true if the USB function is enabled.
      • getDefaultFunction

        public String getDefaultFunction()
        Returns the current default USB function.
        Returns:
        name of the default function.
      • setCurrentFunction

        public void setCurrentFunction(String function,
                              boolean makeDefault)
        Sets the current USB function. If function is null, then the current function is set to the default function.
        Parameters:
        function - name of the USB function, or null to restore the default function
        makeDefault - true if the function should be set as the new default function
      • setMassStorageBackingFile

        public void setMassStorageBackingFile(String path)
        Sets the file path for USB mass storage backing file.
        Parameters:
        path - backing file path


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 659 / . Delta: 0.03636 с