I am using the Android USB host and an intent to open an app when a device is connected to the phone. However, if the app is open, I do not want it to open again.
Below is the relevant code from the manifest file:
<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" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
I have Java code that can detect the device if the app is already open, so no need for the app to open again. In practice, this is just an annoyance. The app is open, and another "copy" opens on top of it.