I have an application using USB/Serial and USB audio devices. In the manifest.xml file I have the following section, used to make the app start when a specific USB serial device is connected:
Then the resource file is created from manifest.xml too:
In the main code, I'm using BroadcastReceiver library to capture the following events:
I need this to handle the situations when USB devices are connected/disconnected when the application is running. UNfortunately because USB_DEVICE_ATTACHED event is captured through the manifest file, the BroadcastReceiver even is no more triggered inside the app for the same event, only for USB_DEVICE_DETACHED
What can I do to capture this event from the app code?
Thank you.
Dan
B4X:
AddActivityText(main, <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" />)
Then the resource file is created from manifest.xml too:
B4X:
CreateResource(xml, device_filter.xml,
<resources>
<!-- 0x0403 / 0x6015: FTDI FT230XS UART -->
<usb-device vendor-id="1027" product-id="24597" />
</resources>
)
In the main code, I'm using BroadcastReceiver library to capture the following events:
B4X:
Broadcast.addAction("android.hardware.usb.action.USB_DEVICE_DETACHED")
Broadcast.addAction("android.hardware.usb.action.USB_DEVICE_ATTACHED")
I need this to handle the situations when USB devices are connected/disconnected when the application is running. UNfortunately because USB_DEVICE_ATTACHED event is captured through the manifest file, the BroadcastReceiver even is no more triggered inside the app for the same event, only for USB_DEVICE_DETACHED
What can I do to capture this event from the app code?
Thank you.
Dan