Page 1 of 1

Usb device attached

Posted: 03 Jun 2017 19:01
by fagci
Hello.
I use General broadcast trigger to watch for usb device attaching.

In debug log I see:

Code: Select all

04.06.2017 01:21:12.560 Trigger 'USB_DEVICE_ATTACHED' intent bundle UsbDevice device=UsbDevice[mName=/dev/bus/usb/001/029,mVendorId=3034,mProductId=10296,mClass=0,mSubclass=0,mProtocol=0,mManufacturerName=Realtek,mProductName=RTL2838UHIDIR,mVersion=2.0,mSerialNumber=00000001,mConfigurations=[ UsbConfiguration[mId=1,mName=USB2.0-Bulk&Iso,mAttributes=128,mMaxPower=250,mInterfaces=[ UsbInterface[mId=0,mAlternateSetting=0,mName=Bulk-In, Interface,mClass=255,mSubclass=255,mProtocol=255,mEndpoints=[ UsbEndpoint[mAddress=129,mAttributes=2,mMaxPacketSize=512,mInterval=0]] UsbInterface[mId=1,mAlternateSetting=0,mName=Bulk-In, Interface,mClass=255,mSubclass=255,mProtocol=255,mEndpoints=[]]] 
and use this script to get properties:

Code: Select all

b = getBundle("device");
v = getString(b,"mProductName");
but that throws me exception about variable "b", it is not bundle. Whats wrong?

Re: Usb device attached

Posted: 03 Jun 2017 19:53
by Martin
Hi,

UsbDevice is indeed not a bundle. See this page for a description of the class:
https://developer.android.com/reference ... evice.html

There's probably no way to access this extra, maybe with getParcelableAsString but that might not be very useful to work with the UsbDevice. I could add a new function to get Parcelables as is then you could use the Java features of action Script to use it.

Regards,
Martin

Re: Usb device attached

Posted: 04 Jun 2017 05:34
by fagci
Thank you, Martin. getParcelableAsString() works pretty well for me.