android.hardware.USB类介绍
在最新的Android版本中,android.hardware.USB是一个新增类,提供了USB相关事件的插拔,以及状态模式的广播。这里,可以看到USB连接、断开、是否为U盘、ADB模式等等。定义如下
public class Usb {
public static final String ACTION_USB_CONNECTED =
"android.hardware.action.USB_CONNECTED";
public static final String ACTION_USB_DISCONNECTED =
"android.hardware.action.USB_DISCONNECTED";
public static final String ACTION_USB_STATE =
"android.hardware.action.USB_STATE";
public static final String USB_CONNECTED = "connected";
public static final String USB_FUNCTION_MASS_STORAGE = "mass_storage";
public static final String USB_FUNCTION_ADB = "adb";
public static final String USB_FUNCTION_RNDIS = "rndis";
public static final String USB_FUNCTION_MTP = "mtp";
public static final String USB_FUNCTION_ENABLED = "enabled";
public static final String USB_FUNCTION_DISABLED = "disabled";