Android Question USB Serial: Smartphone won't find USB

tooob

Member
Licensed User
Longtime User
Hello community,

I have the problem, that my programm cannot find a device on USB. It has USB On the Go and I used a USB On the Go cable. My smartphone finds the USB device, so I cannot understand why my programm won't find it.

Here is my code:

B4X:
Sub Process_Globals
    Dim usbb As UsbSerial
    Dim aStreams As AsyncStreams
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Dim dev As Int
    Dim u As Int

    Activity.LoadLayout("main")
    If usbb.HasPermission(dev) = False Then
        usbb.RequestPermission(dev)
        u = usbb.Open(115200,dev)
        usbb.SetParameters(115200,usbb.DATABITS_8,usbb.STOPBITS_1,usbb.PARITY_NONE)
        If u <> usbb.USB_NONE Then
            ToastMessageShow("verbindung erfolgreich", False)
            aStreams.Initialize(usbb.GetInputStream,usbb.GetOutputStream,"aStreams")
        Else
            ToastMessageShow("verbindung fehlgeschlagen",False)
        End If
        If usbb.UsbPresent(dev) = usbb.USB_NONE Then
            Msgbox("Kein USb gerät angeschlossen","fehler")
        End If
    End If
End Sub

I hope someone can help me.

sincerly, Tooob

Edit: I use a HTC desire
 

tooob

Member
Licensed User
Longtime User
Thanks for your help Erel.
I did it and got this code: 778342

My Api claims support and Classes were found, but no Device detected. But I can open my usb stick on my smartphone, so I don't know why the programm couldn't detect it
 
Upvote 0

tooob

Member
Licensed User
Longtime User
ah I see thank you very much Erel. I want to connect a temperature sensor to my android device and wanted to test it beforehand.
 
Upvote 0
Top