Really, uhmmm i tried it but it doesn't seem to work.Have you tried it, I would think it would give the same result as the device is then missing and can't communicate, I would think it would trigger the broadcast receiver if you pull out the usb cable.
I just tried it with a midi keyboard and the broadcast receiver was triggered.
I'm using an OTG adapter to connect between the medical device and the android phone.Does the USB cable plug directly into the machine, or is there an interface of some kind in between?
how are you registering the broadcast receiver? maybe there's something i'm doing wrong, as i mentioned before, if i unplug the cable from the android device the broadcast receiver event gets triggered, but i need to see when the usb cable gets unplugged from the medical device.Is that just a cable adapter?
uhmmm, i wonder why is not doing the same thing then?Then it's the same as I am using. If the device is connected and communicating, and I pull the cable (from either end), the broadcast receiver gets triggered.
yes it is still working.Have you tested that it's still working if you pull the cable from the android device end? Just in case.
i'm using my android galaxy s5, with android version 4.4.2That's a strange one. What device are you using, although I can't imagine how that would make any difference.
how are you registering the broadcast receiver?
Broadcast.Initialize("BroadcastReceiver")
Broadcast.addAction("android.hardware.usb.action.USB_DEVICE_DETACHED")
Broadcast.registerReceiver("")
Sub BroadcastReceiver_OnReceive(Action As String,i As Object)
Dim Intent1 As Intent = i
If Intent1.HasExtra("device") Then
Dim JO As JavaObject = Intent1
'Extra 'device' is not serializable, need to get it with getParcelableExtra
Dim ud As UsbDevice = JO.RunMethod("getParcelableExtra",Array As Object("device"))
If MidiUSBMan.Device = ud Then
ToastMessageShow("USB Midi device disconnected",False)
MidiUSBMan.USBAvailable = False
'Reset device and interface so plugging back in will reinitialize
MidiUSBMan.Device = Null
MidiUSBMan.Interface = Null
btnConnect.Enabled = True
End If
End If
End Sub
what does the midiUSBMan.USVAvailable = True do?And the receiver sub is:
B4X:Sub BroadcastReceiver_OnReceive(Action As String,i As Object) Dim Intent1 As Intent = i If Intent1.HasExtra("device") Then Dim JO As JavaObject = Intent1 'Extra 'device' is not serializable, need to get it with getParcelableExtra Dim ud As UsbDevice = JO.RunMethod("getParcelableExtra",Array As Object("device")) If MidiUSBMan.Device = ud Then ToastMessageShow("USB Midi device disconnected",False) MidiUSBMan.USBAvailable = False 'Reset device and interface so plugging back in will reinitialize MidiUSBMan.Device = Null MidiUSBMan.Interface = Null btnConnect.Enabled = True End If End If End Sub
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?