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