I have an application that starts using the intent-filter action. The problem is that every time an event / action occurs, Android displays a dialog box asking you to start the application, even if it is already running.
I want the behavior to be as follows:
- The user asked to start the application if the application is not open.
- The dialog is not displayed if the application is running in the foreground.
Is there a way to achieve both of these goals? I am targeting Android 4.0.
change
Here is my intent filter:
<intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> <intent-filter> <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" /> </intent-filter> <intent-filter> <action android:name="android.hardware.usb.action.USB_DEVICE_DETACHED" /> </intent-filter> <meta-data android:name="android.hardware.usb.action.USB_DEVICE_DETACHED" android:resource="@xml/device_filter" />
Brian source share