當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。