本文整理匯總了Java中android.hardware.usb.UsbManager.ACTION_USB_DEVICE_ATTACHED屬性的典型用法代碼示例。如果您正苦於以下問題:Java UsbManager.ACTION_USB_DEVICE_ATTACHED屬性的具體用法?Java UsbManager.ACTION_USB_DEVICE_ATTACHED怎麽用?Java UsbManager.ACTION_USB_DEVICE_ATTACHED使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類android.hardware.usb.UsbManager
的用法示例。
在下文中一共展示了UsbManager.ACTION_USB_DEVICE_ATTACHED屬性的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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);
}
}
示例3: 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;
}
}
}
示例4: 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;
}
}
示例5: 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();
}
示例6: onReceive
@Override
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
final UsbDevice device = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
if (device == null)
return;
switch (action) {
case ACTION_USB_PERMISSION:
boolean granted = intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false);
if (!granted) {
Log.e(TAG, "permission denied for device: " + device);
setState(STATE_ERROR, R.string.error_no_permission);
return;
}
performUsbPermissionCallback(device);
break;
case UsbManager.ACTION_USB_DEVICE_ATTACHED:
if (!isRoyaleDevice(device)) return;
if (mConn != null) {
Log.i(TAG, "Another picoflexx attached");
return;
}
if (mUsbManager.hasPermission(device)) {
performUsbPermissionCallback(device);
return;
}
mUsbManager.requestPermission(device, mUsbPi);
break;
case UsbManager.ACTION_USB_ACCESSORY_DETACHED:
if (!isRoyaleDevice(device))
return;
Log.i(TAG, "did the device disappear beneath us?");
break;
}
}