本文整理汇总了Java中android.hardware.usb.UsbManager.ACTION_USB_DEVICE_DETACHED属性的典型用法代码示例。如果您正苦于以下问题:Java UsbManager.ACTION_USB_DEVICE_DETACHED属性的具体用法?Java UsbManager.ACTION_USB_DEVICE_DETACHED怎么用?Java UsbManager.ACTION_USB_DEVICE_DETACHED使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.hardware.usb.UsbManager
的用法示例。
在下文中一共展示了UsbManager.ACTION_USB_DEVICE_DETACHED属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: onCreate
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_usb);
mStatusView = (TextView) findViewById(R.id.text_status);
mResultView = (TextView) findViewById(R.id.text_result);
mUsbManager = getSystemService(UsbManager.class);
// Detach events are sent as a system-wide broadcast
IntentFilter filter = new IntentFilter(UsbManager.ACTION_USB_DEVICE_DETACHED);
registerReceiver(mUsbReceiver, filter);
handleIntent(getIntent());
}
示例3: onReceive
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
Log.d(TAG, "onReceive - got action: " + action);
switch (action) {
case ACTION_USB_PERMISSION:
handleUsbPermission(intent);
break;
case UsbManager.ACTION_USB_DEVICE_ATTACHED:
handleDeviceAttached(intent);
break;
case UsbManager.ACTION_USB_DEVICE_DETACHED:
handleDeviceDetached(intent);
break;
default:
Log.w(TAG, "onReceive - do not known how to handle action: " + action);
}
}
示例4: onReceive
@Override
public void onReceive(final Context context, final Intent intent) {
String action = intent.getAction();
switch (action) {
case DongleConst.DEVICE_TO_DONGLE_OPEN_USB:
startSearchUSBSerialDeviceThread();
break;
case DongleConst.DEVICE_TO_DONGLE_CHECK_USB:
sendStatus(mStatus);
break;
case DongleConst.DEVICE_TO_DONGLE_CLOSE_USB:
case UsbManager.ACTION_USB_ACCESSORY_DETACHED:
case UsbManager.ACTION_USB_DEVICE_DETACHED:
closeDevice();
setStatus(DongleConst.STATUS_DONGLE_NOCONNECT);
break;
}
}
示例5: onReceive
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action == null) {
Log.w(TAG, "onReceive: received a null action on broadcast receiver");
return;
}
Log.d(TAG, "BroadcastReceiver onReceive " + action);
switch (action) {
case PowerManager.ACTION_DEVICE_IDLE_MODE_CHANGED:
case ConnectivityManager.CONNECTIVITY_ACTION:
case RingApplication.DRING_CONNECTION_CHANGED: {
updateConnectivityState();
break;
}
case UsbManager.ACTION_USB_DEVICE_ATTACHED:
case UsbManager.ACTION_USB_DEVICE_DETACHED: {
mHardwareService.initVideo();
break;
}
}
}
示例6: onReceive
@Override
public void onReceive(Context context, Intent intent) {
if (DEBUG) Log.d(TAG, "Broadcast intent received:" + intent);
TvApplication.setCurrentRunningProcess(context, true);
if (!Features.TUNER.isEnabled(context)) {
enableTunerTvInputService(context, false);
return;
}
switch (intent.getAction()) {
case Intent.ACTION_BOOT_COMPLETED:
case TvApplication.ACTION_APPLICATION_FIRST_LAUNCHED:
case UsbManager.ACTION_USB_DEVICE_ATTACHED:
case UsbManager.ACTION_USB_DEVICE_DETACHED:
if (TunerInputInfoUtils.isBuiltInTuner(context)) {
enableTunerTvInputService(context, true);
break;
}
// Falls back to the below to check USB tuner devices.
boolean enabled = isUsbTunerConnected(context);
mHandler.removeMessages(MSG_ENABLE_INPUT_SERVICE);
if (enabled) {
// Need to check if DVB driver is accessible. Since the driver creation
// could be happen after the USB event, delay the checking by
// DVB_DRIVER_CHECK_DELAY_MS.
mHandler.sendMessageDelayed(
mHandler.obtainMessage(MSG_ENABLE_INPUT_SERVICE, context),
DVB_DRIVER_CHECK_DELAY_MS);
} else {
enableTunerTvInputService(context, false);
}
break;
}
}
示例7: usbConnection
private void usbConnection() {
IntentFilter filter = new IntentFilter(UsbManager.ACTION_USB_DEVICE_ATTACHED);
registerReceiver(mUsbAttachReceiver , filter);
filter = new IntentFilter(UsbManager.ACTION_USB_DEVICE_DETACHED);
registerReceiver(mUsbDetachReceiver , filter);
mPermissionIntent = PendingIntent.getBroadcast(this, 0, new Intent(ACTION_USB_PERMISSION), 0);
filter = new IntentFilter(ACTION_USB_PERMISSION);
registerReceiver(mUsbReceiver, filter);
showDevices();
}
示例8: onReceive
@Override
public void onReceive(final Context context, final Intent intent) {
String action = intent.getAction();
boolean bCloseFlag = intent.getBooleanExtra(EXTRA_FINISH_FLAG, false);
switch (action) {
case DongleConst.DEVICE_TO_DONGLE_OPEN_USB_RESULT:
int resultId = intent.getIntExtra("resultId", 0);
if (resultId == DongleConst.CAN_NOT_FIND_USB) {
mTextViewCommment.setText(R.string.not_found_arduino);
} else if (resultId == DongleConst.FAILED_OPEN_USB) {
mTextViewCommment.setText(R.string.failed_open_usb);
} else if (resultId == DongleConst.FAILED_CONNECT_DONGLE) {
mTextViewCommment.setText(R.string.failed_connect_dongle);
} else if (resultId == DongleConst.SUCCESS_CONNECT_DONGLE) {
mTextViewCommment.setText(R.string.success_connect_dongle);
String bRouteId = mPrefUtil.getBRouteId();
String bRoutePassword = mPrefUtil.getBRoutePass();
if (bRouteId == null || bRouteId.length() == 0) {
Toast.makeText(getContext(), R.string.setting_error_b_route_id, Toast.LENGTH_LONG).show();
viewSettingActivity();
} else if (bRoutePassword == null || bRoutePassword.length() == 0) {
Toast.makeText(getContext(), R.string.setting_error_b_route_password, Toast.LENGTH_LONG).show();
viewSettingActivity();
} else {
checkAndFinish(bCloseFlag);
}
}
break;
case DongleConst.DEVICE_TO_DONGLE_CHECK_USB_RESULT:
int statusId = intent.getIntExtra("statusId", 0);
if (statusId == DongleConst.STATUS_DONGLE_NOCONNECT) {
mDongleStatus = DongleConst.STATUS_DONGLE_NOCONNECT;
} else if (statusId == DongleConst.STATUS_DONGLE_INIT) {
mDongleStatus = DongleConst.STATUS_DONGLE_INIT;
} else if (statusId == DongleConst.STATUS_DONGLE_RUNNING) {
mTextViewCommment.setText(R.string.success_connect);
mDongleStatus = DongleConst.STATUS_DONGLE_RUNNING;
checkAndFinish(bCloseFlag);
}
break;
case UsbManager.ACTION_USB_DEVICE_DETACHED:
mTextViewCommment.setText(R.string.disconnect_usb);
mDongleStatus = DongleConst.STATUS_DONGLE_NOCONNECT;
Intent closeIntent = new Intent(DongleConst.DEVICE_TO_DONGLE_CLOSE_USB);
mContext.sendBroadcast(closeIntent);
checkAndFinish(bCloseFlag);
break;
}
}