當前位置: 首頁>>代碼示例>>Java>>正文


Java UsbManager.ACTION_USB_DEVICE_ATTACHED屬性代碼示例

本文整理匯總了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
    }
}
 
開發者ID:videgro,項目名稱:Ships,代碼行數:26,代碼來源:MainActivity.java

示例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);
    }
}
 
開發者ID:coinblesk,項目名稱:coinblesk-client-gui,代碼行數:19,代碼來源:NFCServerACSCLTV.java

示例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;
        }
    }
}
 
開發者ID:savoirfairelinux,項目名稱:ring-client-android,代碼行數:22,代碼來源:DRingService.java

示例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;
    }
}
 
開發者ID:trevd,項目名稱:android_packages_apps_tv,代碼行數:34,代碼來源:TunerInputController.java

示例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();
}
 
開發者ID:yushulx,項目名稱:android-usb-monitor,代碼行數:12,代碼來源:MainActivity.java

示例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;
    }
}
 
開發者ID:nasa,項目名稱:astrobee_android,代碼行數:43,代碼來源:MainActivity.java


注:本文中的android.hardware.usb.UsbManager.ACTION_USB_DEVICE_ATTACHED屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。