Android Question Activity parameter to Java method from B4A

baron

Member
Licensed User
Hi Erel,

I'm trying to interface with a 3rd party Android credit card app from B4A. It will start the app, but locks up. I suspect the 1st parameter to initiatePayment is wrong. It locks up when I call it with the B4A Activity.

Note that TransactionRequest is a structure which is created by another method in the same jar. It seems to work OK, so I'm assuming the problem is the 1st parameter.

public void Stage3(Activity BA) {

// create a currency object with specified locale

try {

String orderId = "456789";

PaylevenApi.initiatePayment(BA, orderId, request);

}
catch (NumberFormatException e) {
Toast.makeText(getApplicationContext(), "invalid_amount", Toast.LENGTH_LONG).show();
}
}


Supplied documentation is as follows:

"Issues a TransactionRequest to the app. You need to override onActivityResult of your Activity to receive the response"
Parameters:
activity - the activity that will receive the result
orderId - a unique id that identifies the payment.
 

walterf25

Expert
Licensed User
Hi Erel,

I'm trying to interface with a 3rd party Android credit card app from B4A. It will start the app, but locks up. I suspect the 1st parameter to initiatePayment is wrong. It locks up when I call it with the B4A Activity.

Note that TransactionRequest is a structure which is created by another method in the same jar. It seems to work OK, so I'm assuming the problem is the 1st parameter.

public void Stage3(Activity BA) {

// create a currency object with specified locale

try {

String orderId = "456789";

PaylevenApi.initiatePayment(BA, orderId, request);

}
catch (NumberFormatException e) {
Toast.makeText(getApplicationContext(), "invalid_amount", Toast.LENGTH_LONG).show();
}
}


Supplied documentation is as follows:

"Issues a TransactionRequest to the app. You need to override onActivityResult of your Activity to receive the response"
Parameters:
activity - the activity that will receive the result
orderId - a unique id that identifies the payment.
I think it should be something like this;
B4X:
public void Stage3(BA ba) {

// create a currency object with specified locale

try {

String orderId = "456789";

PaylevenApi.initiatePayment(ba.Activity, orderId, request);

}
catch (NumberFormatException e) {
Toast.makeText(ba.context, "invalid_amount", Toast.LENGTH_LONG).show();
}
}
i'm not familiar with your library, but this should work.

Good luck!
 

warwound

Expert
Licensed User
ba.Activity will be null unless:

The java class is marked with the @BA.ActivtyObject annotation.

And

The Stage3 method is callled from an Activty (not a Service or Code module).
 
Top