本文整理汇总了Java中android.hardware.usb.UsbManager.ACTION_USB_ACCESSORY_ATTACHED属性的典型用法代码示例。如果您正苦于以下问题:Java UsbManager.ACTION_USB_ACCESSORY_ATTACHED属性的具体用法?Java UsbManager.ACTION_USB_ACCESSORY_ATTACHED怎么用?Java UsbManager.ACTION_USB_ACCESSORY_ATTACHED使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.hardware.usb.UsbManager
的用法示例。
在下文中一共展示了UsbManager.ACTION_USB_ACCESSORY_ATTACHED属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onReceive
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
if (action != null) {
switch (action) {
case UsbManager.ACTION_USB_DEVICE_DETACHED:
final UsbDevice detDevice = (UsbDevice) intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
final String detMsg="Device DEtached";
Log.v(TAG,detMsg+" "+detDevice);
Analytics.getInstance().logEvent(Analytics.CATEGORY_RTLSDR_DEVICE,detMsg,detDevice.toString());
break;
case UsbManager.ACTION_USB_DEVICE_ATTACHED:
case UsbManager.ACTION_USB_ACCESSORY_ATTACHED:
final UsbDevice attDevice = (UsbDevice) intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
final String attMsg="Device atached";
Log.v(TAG,attMsg+" "+attDevice);
Analytics.getInstance().logEvent(Analytics.CATEGORY_RTLSDR_DEVICE,attMsg,attDevice.toString());
deviceAttached();
break;
default:
// Nothing to do
break;
} // END SWITCH
}
}
示例2: onNewIntent
/**
* ACTION_USB_ACCESSORY_ATTACHED is an Activity Broadcast.
* Thus this needs to be here not inside {@link USBConnectionManager}
*/
@Override
protected void onNewIntent(Intent intent) {
switch (intent.getAction()) {
case UsbManager.ACTION_USB_ACCESSORY_ATTACHED:
BridgeApplication.getInstance().getBus().post(new USBConnectionManager.USBConnectionEvent(true));
break;
}
super.onNewIntent(intent);
}