Hi Erel, hi all.
I often find wrapper aar obfuscated. In this way it becomes difficult to write wrappers.
So i think that the JavaObject is the right way to interface any JAR / AAR in our B4 programs.
I am working on one of these libraries AAR.
In the AAR file i have the following lines of code:
The Class start so:
Now i have this code in B4A:
Is right this line in B4A ?:
This is call in Java:
Thank you
Marco
I often find wrapper aar obfuscated. In this way it becomes difficult to write wrappers.
So i think that the JavaObject is the right way to interface any JAR / AAR in our B4 programs.
I am working on one of these libraries AAR.
In the AAR file i have the following lines of code:
The Class start so:
B4X:
public class IrHandler
{
public static final String libVersion = "1.15";
private static boolean a = Build.VERSION.SDK_INT >= 11;
public static final int COM_IR = 1;
......
public IrHandler(Context context, Handler handler)
{
this.mContext = context;
mHandler = handler;
mAudioManager = (AudioManager)context.getSystemService("audio");
.......
Now i have this code in B4A:
B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim jo As JavaObject
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("1")
'Inizializzo oggetto JavaObject
If FirstTime Then jo.InitializeContext
End Sub
Sub GetContext As JavaObject
Return GetBA.GetField("context")
End Sub
Sub GetHandler As JavaObject
Return GetBA.GetField("handler")
End Sub
Sub GetBA As JavaObject
Dim jo As JavaObject
Dim cls As String = Me
cls = cls.SubString("class ".Length)
jo.InitializeStatic(cls)
Return jo.GetFieldJO("processBA")
End Sub
Sub Cooffee As JavaObject
Dim jo As JavaObject
Return jo.InitializeNewInstance("com.rft.irlib.IrHandler", Array(GetContext, GetHandler))
End Sub
Sub btn_start_Click
'PowerStart
Dim batteria, memtot, memused, nfile As Int
Dim sn, version As String
Dim temperature As Float
batteria = Cooffee.RunMethod("GetBattery", Null)
Log("Batteria: " & batteria)
memtot = Cooffee.RunMethod("GetMemTot", Null)
Log("MemTot: " & memtot)
memused = Cooffee.RunMethod("GetMemUsed", Null)
Log("MemUsed: " & memused)
nfile = Cooffee.RunMethod("GetNFile", Null)
Log("NFile: " & nfile)
sn = Cooffee.RunMethod("GetSN", Null)
Log("SN: " & sn)
version = Cooffee.RunMethod("GetVersion", Null)
Log("Version: " & version)
temperature = Cooffee.RunMethod("GetTemperature", Null)
Log("Temperature: " & temperature)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Is right this line in B4A ?:
Return jo.InitializeNewInstance("com.rft.irlib.IrHandler", Array(GetContext, GetHandler))
This is call in Java:
public IrHandler(Context context, Handler handler)
{
this.mContext = context;
mHandler = handler;
mAudioManager = (AudioManager)context.getSystemService("audio");
.......
Thank you
Marco