Configure USB Device Attachment Notifications
masterTo ensure your app is notified when a USB device is attached, you must add a device_filter.xml file to your res/xml/ directory and configure your AndroidManifest.xml with an intent filter for USB_DEVICE_ATTACHED.
<activity
android:name="..."
...>
<intent-filter>
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
</intent-filter>
<meta-data
android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
android:resource="@xml/device_filter" />
</activity>