Android Question passing String[] args via java object

apty

Active Member
Licensed User
Longtime User
i have a java method that depends on arguments passed to it. I would like to pass these arguments to the inline java method via java object.
for example
java
B4X:
public void stx(String[] argsx) throws Exception
{
    otherMethod.create(argsx);
}

Now i want to pass the arguments via java object like so (tried it this way but the app force closes):
B4X:
J.RunMethod("stx",Array(args))

i have defined args as shown below:
B4X:
Dim args() As String
    args = Array As String ("mx","lp","dg")

in other words, i want to pass "mx","lp","dg" as a single string to the java method.

How do i do it?
 

apty

Active Member
Licensed User
Longtime User
i am really sorry i framed the question the wrong way. The java method has an array of strings as shown below:
B4X:
public void stx(String aa,String bb, String cc) throws Exception
{
    otherMethod.create(new String[]{aa,bb,cc});
}

Now i want to combine the aa,bb,cc to be a single string and pass it on b4a javaobject then i will modify the java method "stx" to accept one string instead of 3.
 
Upvote 0

apty

Active Member
Licensed User
Longtime User
thanks. I mean i want to convert the above method to be something like the below:
B4X:
public void stx(String[] args) throws Exception
{
    otherMethod.create(new String[]{args});
}

where args now contain aa,bb,cc which i will pass through a java object
 
Upvote 0
Top