当前位置: 首页>>代码示例>>Java>>正文


Java UsbManager.ACTION_USB_DEVICE_DETACHED属性代码示例

本文整理汇总了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
    }
}
 
开发者ID:videgro,项目名称:Ships,代码行数:26,代码来源:MainActivity.java

示例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());
}
 
开发者ID:androidthings,项目名称:sample-usbenum,代码行数:16,代码来源:UsbActivity.java

示例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);
    }
}
 
开发者ID:coinblesk,项目名称:coinblesk-client-gui,代码行数:19,代码来源:NFCServerACSCLTV.java

示例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;
    }
}
 
开发者ID:DeviceConnect,项目名称:DeviceConnect-Android,代码行数:18,代码来源:SmartMeterMessageService.java

示例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;
        }
    }
}
 
开发者ID:savoirfairelinux,项目名称:ring-client-android,代码行数:22,代码来源:DRingService.java

示例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;
    }
}
 
开发者ID:trevd,项目名称:android_packages_apps_tv,代码行数:34,代码来源:TunerInputController.java

示例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();
}
 
开发者ID:yushulx,项目名称:android-usb-monitor,代码行数:12,代码来源:MainActivity.java

示例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;
    }
}
 
开发者ID:DeviceConnect,项目名称:DeviceConnect-Android,代码行数:50,代码来源:SmartMeterConnectFragment.java


注:本文中的android.hardware.usb.UsbManager.ACTION_USB_DEVICE_DETACHED属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。