I actually think this whole piece of sample code isn't very good, it always shows me the dialog twice:
'initialize Usb Manager
device_UsbMan.Initialize
'create an accessory collection
Dim listAccessories () As UsbAccessory
' get accessories, main throw exception
Try
listAccessories = device_UsbMan.GetAccessories
For i = 0 To listAccessories.Length - 1
If listAccessories(i).Description = "thingstank" Then
device_UsbAcc = listAccessories(i)
End If
Next
If device_UsbAcc <> Null Then
Dim Permission As Boolean
Permission= device_UsbMan.HasAccessoryPermission(device_UsbAcc)
If Permission==True Then
device_UsbMan.OpenAccessory(device_UsbAcc)
If device_Stream.IsInitialized==False Then
Try
device_Stream.Initialize(device_UsbAcc.InputStream,device_UsbAcc.OutputStream,"deviceStream")
Catch
End Try
Else
End If
Else
device_UsbMan.RequestAccessoryPermission(device_UsbAcc)
Permission= device_UsbMan.HasAccessoryPermission(device_UsbAcc)
If Permission Then
device_UsbMan.OpenAccessory(device_UsbAcc)
Else
End If
If device_Stream.IsInitialized==False Then
Try
device_Stream.InitializePrefix(device_UsbAcc.InputStream,False,device_UsbAcc.OutputStream , "deviceStream")
Catch
End Try
Else
End If
End If
Else
End If
Catch
'do nothing
ToastMessageShow ("Could not get connected accessories!",False)
End Try