USB Intent - receive event when usb device connected

qsrtech

Active Member
Licensed User
Longtime User
Hi, I'm having trouble figuring out when/where/how to notify the OS of a callback sub to be notified when a usb device is connected.

I already have my manifest with this intent filter:

android.hardware.usb.action.USB_DEVICE_ATTACHED

I'm using the USBSerial example for registering my intent/device. (modified to include pl2303)

Basically, I want to get notified when a device(i.e. printer) has been re-connected if it was disconnected for whatever reason.

Thanks!
John
 

qsrtech

Active Member
Licensed User
Longtime User
Hi, I've added multiple "activities" within my app to potentially handle a USB intent filter. I get multiple items in my intent filter pop up list but they all say the same thing. Is there a way to change what the pop up list displays for each intent filter?
 
Upvote 0

qsrtech

Active Member
Licensed User
Longtime User
Sorry I guess my question was a little confusing. I'd like to be able to change the display name for my app/activity when the OS pops up a selection list when a USB is plugged in. Within my one app I have potentially several different activities that could handle the newly connected USB device and the OS displays the same name for both filters. I'd like to be able to differentiate them for the end user. For example if they plug in a printer they will choose the "printer" activity. If it's something else then the "Main" activity might handle it, or any other specific activity that might be created to handle specific USB devices in the future.

Here's some manifest code:
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" />) 'is there a way to put in the name to display in the OS selection list?
  AddActivityText(printersettings, <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" />)'is there a way to put in the name to display in the OS selection list?
 
Upvote 0
Top