本文整理匯總了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);
}