Android Question Invoking a Inline Method Class with Activity

EduardoElias

Well-Known Member
Licensed User
Longtime User
Hi there !

I am trying to wrap a library and I am having a big issue in passing the Activity for the java method:

B4X:
Sub Activity_Create(FirstTime As Boolean)
    
    If FirstTime Then
        nexu.InitializeContext
    End If
    
    nexupayment = nexu.InitializeNewInstance("yashar.ynexu.main.nexutransaction", Null)

    nexupayment.RunMethod("Ativar", Array(GetContext, Activity))
End Sub

#if java
import android.content.Context;
import android.app.Activity;

import java.util.HashMap;
import java.util.List;

import ca.nexu.nexupayment.NexuPayment;
import ca.nexu.nexupayment.NexuPaymentPrinterListener;
import ca.nexu.nexupayment.NexuPaymentTransactionListener;

public static class nexutransaction implements NexuPaymentTransactionListener, NexuPaymentPrinterListener {

    public nexutransaction() {
        // Required empty public constructor
    }

    public NexuPayment nexuPayment;

    public void Ativar(Context c, Activity a) {

        BA.Log("Transaction.Ativar");

        NexuPayment.loadSDK(null);
    
        nexuPayment = new NexuPayment(this, c, a, null, null);

I get this:
java.lang.RuntimeException: Method: Ativar not matched.

Tried other ways using BA.activity

What is the correct way to use the activity inside the Java Inline code. ?
 

EduardoElias

Well-Known Member
Licensed User
Longtime User
Upvote 0

Jeffrey Cameron

Well-Known Member
Licensed User
Longtime User
I don't know enough about Java to give you a coherent answer. I would try utilizing the method illustrated in the post:
B4X:
Dim J as JavaObject
J.initializeContext
nexupayment.RunMethod("Ativar", Array(GetContext, j))
and see if that works or not.
 
Upvote 0

EduardoElias

Well-Known Member
Licensed User
Longtime User
I don't know enough about Java to give you a coherent answer. I would try utilizing the method illustrated in the post:
B4X:
Dim J as JavaObject
J.initializeContext
nexupayment.RunMethod("Ativar", Array(GetContext, j))
and see if that works or not.
1612548170982.png


At least it let me call the method but gives this error
 
Upvote 0

Jeffrey Cameron

Well-Known Member
Licensed User
Longtime User
I can't tell what the error is from that screenshot (the relevant portion is below your capture). It's generally best to post the logs as text using the insert code tags (if it's too long you can wrap the code tags in the Spoiler tags to shorten it).
 
Upvote 0
Top