Android Question Incompatible Types USB

geeky121

New Member
Hello, I'm newer to B4A, and I ran into this program issue using this tutorial:

https://www.b4x.com/android/forum/threads/arduino-adk-consummation.27590/

And I ran into this error while compiling using the same code as the tutorial provides:

error: incompatible types: UsbAccessoryWrapper cannot be converted to UsbAccessory
if (anywheresoftware.b4a.keywords.Common.Not(_v6.HasAccessoryPermission((android.hardware.usb.UsbAccessory)(_v7)))) {

Does anyone know if there is a fix to this or is something else wrong?

Thanks!
 

geeky121

New Member
B4X:
Sub BtnConnect_Click
    Dim Accs() As UsbAccessory
    USBman.Initialize
    Accs = USBman.GetAccessories
    If Accs.Length > 0 Then
        ADK = Accs(0)
        If Not(USBman.HasAccessoryPermission(ADK)) Then
            USBman.RequestAccessoryPermission(ADK)
        Else          
            USBman.OpenAccessory(ADK)
            AStream.Initialize(ADK.InputStream, ADK.OutputStream, "AStream")
            BtnConnect.Enabled = False
            ConnectEnabled = False
        End If
    End If  
End Sub

B4X:
        If Not(USBman.HasAccessoryPermission(ADK)) Then
            USBman.RequestAccessoryPermission(ADK)

These two lines create the error. I ran this once already and it worked. When I tried to compile it a second time it started giving me the error.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…