Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- BroadcastReceiver mUsbReceiver = new BroadcastReceiver() {
- public void onReceive(Context context, Intent intent) {
- String action = intent.getAction();
- Log.d(TAG, " onReceive " + action );
- if (UsbManager.ACTION_USB_DEVICE_ATTACHED.equals(action)) {
- UsbDevice device = (UsbDevice)intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
- UsbInterface intf = findAdbInterface(device);
- if (intf != null) {
- log("Found adb interface " + intf);
- Log.d(TAG, "Found adb interface " + intf);
- setAdbInterface(device, intf);
- }
- } else if (UsbManager.ACTION_USB_DEVICE_DETACHED.equals(action)) {
- UsbDevice device = intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
- String deviceName = device.getDeviceName();
- if (mDevice != null && mDevice.equals(deviceName)) {
- log("adb interface removed");
- Log.d(TAG, "adb removed interface " );
- setAdbInterface(null, null);
- }
- }
- }
- };
Add Comment
Please, Sign In to add comment