FileDocCategorySizeDatePackage
DeviceDisconnectedReceiver.javaAPI DocAndroid 5.1 API1887Thu Mar 12 22:22:30 GMT 2015com.android.camerabrowser

DeviceDisconnectedReceiver

public class DeviceDisconnectedReceiver extends android.content.BroadcastReceiver

Fields Summary
private static final String
TAG
private final android.app.Activity
mActivity
private final String
mDeviceName
Constructors Summary
public DeviceDisconnectedReceiver(android.app.Activity activity, String deviceName)


         
        mActivity = activity;
        mDeviceName = deviceName;

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

        UsbDevice device = (UsbDevice)intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
        String deviceName = device.getDeviceName();
        Log.d(TAG, "ACTION_USB_DEVICE_DETACHED " + deviceName);

        // close our activity if the device it is displaying is disconnected
        if (deviceName.equals(mDeviceName)) {
            mActivity.finish();
        }