Android Question (solved, with 1 question) Intent for connected USB-keyboard

Filippo

Expert
Licensed User
Hi all,

Is there an intent-filter that tells me if a USB-keyboard is connected?

I found this, but does not say that it is a USB keyboard.
B4X:
"android.hardware.usb.action.USB_DEVICE_ATTACHED"
 
Last edited:

Filippo

Expert
Licensed User
Now I know how to do that.
For me, it's enough!
B4X:
    If StartingIntent.Action="android.hardware.usb.action.USB_DEVICE_ATTACHED" Then
        ToastMessageShow("USB_DEVICE_ATTACHED:" & StartingIntent.GetExtra("mManufacturerName"), True)
    Else If StartingIntent.Action="android.hardware.usb.action.USB_DEVICE_DETACHED" Then
        ToastMessageShow("USB_DEVICE_DETACHED:" & StartingIntent.GetExtra("mManufacturerName"), True)
    End If
 

Filippo

Expert
Licensed User
B4X:
Log("USB_DEVICE_DETACHED:" & StartingIntent.ExtrasToString))
The line shows approximately:
USB_DEVICE_ATTACHED:Bundle[{device=UsbDevice[mName=/dev/bus/usb/002/002,mVendorId=16700,mProductId=8455,mClass=0,mSubclass=0,mProtocol=0,mManufacturerName=Dell,mProductName=Dell USB Entry Keyboard,mSerialNumber=Null,mConfigurations=[[/QUOTE]
and this line
B4X:
    Log(StartingIntent.GetExtra("mManufacturerName")) -> null
How can I get the "mManufacturerName" ?
 
Top