FileDocCategorySizeDatePackage
UsbDisconnectedReceiver.javaAPI DocAndroid 5.1 API2560Thu Mar 12 22:22:42 GMT 2015com.android.systemui.usb

UsbDisconnectedReceiver

public class UsbDisconnectedReceiver extends android.content.BroadcastReceiver

Fields Summary
private final android.app.Activity
mActivity
private android.hardware.usb.UsbDevice
mDevice
private android.hardware.usb.UsbAccessory
mAccessory
Constructors Summary
public UsbDisconnectedReceiver(android.app.Activity activity, android.hardware.usb.UsbDevice device)

       mActivity = activity;
        mDevice = device;

        IntentFilter filter = new IntentFilter(UsbManager.ACTION_USB_DEVICE_DETACHED);
        activity.registerReceiver(this, filter);
    
public UsbDisconnectedReceiver(android.app.Activity activity, android.hardware.usb.UsbAccessory accessory)

        mActivity = activity;
        mAccessory = accessory;

        IntentFilter filter = new IntentFilter(UsbManager.ACTION_USB_ACCESSORY_DETACHED);
        activity.registerReceiver(this, filter);
    
Methods Summary
public voidonReceive(android.content.Context context, android.content.Intent intent)

        String action = intent.getAction();
        if (UsbManager.ACTION_USB_DEVICE_DETACHED.equals(action)) {
            UsbDevice device = (UsbDevice)intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
            if (device != null && device.equals(mDevice)) {
                mActivity.finish();
            }
        } else if (UsbManager.ACTION_USB_ACCESSORY_DETACHED.equals(action)) {
            UsbAccessory accessory =
                    (UsbAccessory)intent.getParcelableExtra(UsbManager.EXTRA_ACCESSORY);
            if (accessory != null && accessory.equals(mAccessory)) {
                mActivity.finish();
            }
        }