Android Question How to use a .so library in my B4A code (embedded library)

Mike1970

Well-Known Member
Licensed User
Longtime User
Hi guys,
I'm working with a custom-made device, the manufacturer has customized also the device's firmware by adding in it a custom library libUART.so

I'm using that library called (UART) into my app.
My questions now are:
  • To use the "embedded" library with the new device's firmware can I keep the current APP as is (so with a reference into the Library Manager), in the hope the system prioritize the system's embedded one?

  • In the case I cannot do as described in the above point, since I can face systems with the embedded library and system without it, how can I know if the system have or not the "embedded" library and so act accordingly?
All in all, how to use/reference the embedded library using loadLibrary?

P.S.
I asked them how the library should be used, and they told me to use "loadLibrary" (native Android/Java)


At the moment, this is the current use:
B4X:
Sub Class_Globals
    Private bc As ByteConverter 
    Public SerialPort As UART        ' Library by Rui Cardoso: https://www.b4x.com/android/forum/threads/gpio-and-uart.100811/#content
  
    Dim SerialPort_devPath As String = "/dev/tty1WK3"
    Dim SerialPort_eventName As String = "SerialPort"
    Dim SerialPort_baudeRate As Int = 9600
    Dim SerialPort_flags As Int = 0
    Dim bigEndian As Boolean = False
    Dim prefix As Boolean = False
  
End Sub

Public Sub Initialize 
    Try
        SerialPort.Initialize(SerialPort_eventName, SerialPort_devPath, SerialPort_baudeRate, SerialPort_flags, bigEndian, prefix)
    Catch
        LogColor("###################################################", Colors.Red)
        LogColor("# >>>>>>>>>>>>> CRASH PORTA SERIALE <<<<<<<<<<<<< #", Colors.Red)
        LogColor("###################################################", Colors.Red)
        Log(LastException)
    End Try
End Sub

Private Sub SerialPort_NewData (Buffer() As Byte)
   'Do something with the data in the Buffer
End Sub

Thank you for your answer.
 
Last edited:
Top