I have 3rd party .java files that I know work using Java on my desktop. I have managed to create a library using them and most of the functions work. But there are a couple of .java files (classes?) that require parameters sent to them. I am ignorant about Java and constructors and other "fancy" stuff.
When I use B4x Object Browser, I see this:
initTCPlanetIntern
Type
Method
Description
Syntax
initTCPlanetIntern(sw As SwissEph, planet As int, flags As int, offset As double, precalcCount As int, precalcSafetyfactor As double)
Return Value
void
I need to do whatever it takes in order to be able to call the TCPlanet class and have it execute what it does.
Doing this:
Dim tc0 As JavaObject
tc0.InitializeArray("anywheresoftware.b4a.sample1.TCPlanet", Array(swe1, 1, 128*1024, 120)) 'planet, flags, 120
brings an error:
Installing file.
PackageAdded: package:anywheresoftware.b4a.xxxxx
:null,0
java.lang.InstantiationException: java.lang.Class<anywheresoftware.b4a.sample1.TCPlanet> has no zero argument constructor
at java.lang.Class.newInstance(Native Method)
at anywheresoftware.b4a.shell.Shell.createObject(Shell.java:578)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:354)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:246)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
at anywheresoftware.b4a.helen.main.afterFirstLayout(main.java:95)
at anywheresoftware.b4a.helen.main.access$000(main.java:17)
at anywheresoftware.b4a.helen.main$WaitForLayout.run(main.java:80)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
:null,0
java.lang.RuntimeException: Unexpected command: 97
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:414)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:246)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
at anywheresoftware.b4a.helen.main.afterFirstLayout(main.java:95)
at anywheresoftware.b4a.helen.main.access$000(main.java:17)
at anywheresoftware.b4a.helen.main$WaitForLayout.run(main.java:80)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Can someone tell me what to do to make this work?
The TCPlanet.java file looks like this:
package anywheresoftware.b4a.sample1;
import anywheresoftware.b4a.BA.ShortName;
@ShortName("TCPlanet")
public class TCPlanet extends TransitCalculator
{
// private void initTCPlanetIntern(SwissEph sw, int planet, int flags, double offset)
// {
// this(sw, planet, flags, offset, 200, 1.4);
// }
public TCPlanet()
{
}
//public void initTCPlanet(int planet, int flags, double offset)
//{
// initTCPlanetIntern(null, planet, flags, offset);
//}
public void initTCPlanetIntern(SwissEph sw, int planet, int flags, double offset, int precalcCount, double precalcSafetyfactor)
{
// Check parameter: //////////////////////////////////////////////////////
// List of all valid flags:
this.tflags = flags;
etc.
}
Thank you.
When I use B4x Object Browser, I see this:
initTCPlanetIntern
Type
Method
Description
Syntax
initTCPlanetIntern(sw As SwissEph, planet As int, flags As int, offset As double, precalcCount As int, precalcSafetyfactor As double)
Return Value
void
I need to do whatever it takes in order to be able to call the TCPlanet class and have it execute what it does.
Doing this:
Dim tc0 As JavaObject
tc0.InitializeArray("anywheresoftware.b4a.sample1.TCPlanet", Array(swe1, 1, 128*1024, 120)) 'planet, flags, 120
brings an error:
Installing file.
PackageAdded: package:anywheresoftware.b4a.xxxxx
:null,0
java.lang.InstantiationException: java.lang.Class<anywheresoftware.b4a.sample1.TCPlanet> has no zero argument constructor
at java.lang.Class.newInstance(Native Method)
at anywheresoftware.b4a.shell.Shell.createObject(Shell.java:578)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:354)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:246)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
at anywheresoftware.b4a.helen.main.afterFirstLayout(main.java:95)
at anywheresoftware.b4a.helen.main.access$000(main.java:17)
at anywheresoftware.b4a.helen.main$WaitForLayout.run(main.java:80)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
:null,0
java.lang.RuntimeException: Unexpected command: 97
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:414)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:246)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
at anywheresoftware.b4a.helen.main.afterFirstLayout(main.java:95)
at anywheresoftware.b4a.helen.main.access$000(main.java:17)
at anywheresoftware.b4a.helen.main$WaitForLayout.run(main.java:80)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Can someone tell me what to do to make this work?
The TCPlanet.java file looks like this:
package anywheresoftware.b4a.sample1;
import anywheresoftware.b4a.BA.ShortName;
@ShortName("TCPlanet")
public class TCPlanet extends TransitCalculator
{
// private void initTCPlanetIntern(SwissEph sw, int planet, int flags, double offset)
// {
// this(sw, planet, flags, offset, 200, 1.4);
// }
public TCPlanet()
{
}
//public void initTCPlanet(int planet, int flags, double offset)
//{
// initTCPlanetIntern(null, planet, flags, offset);
//}
public void initTCPlanetIntern(SwissEph sw, int planet, int flags, double offset, int precalcCount, double precalcSafetyfactor)
{
// Check parameter: //////////////////////////////////////////////////////
// List of all valid flags:
this.tflags = flags;
etc.
}
Thank you.