Android Question Activity parameter to Java method from B4A

Discussion in 'Android Questions' started by baron, Apr 2, 2015.

  1. baron

    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"
    activity - the activity that will receive the result
    orderId - a unique id that identifies the payment.
  2. walterf25

    walterf25 Well-Known Member Licensed User

    I think it should be something like this;
    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!
  3. warwound

    warwound Expert Licensed User

    ba.Activity will be null unless:

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


    The Stage3 method is callled from an Activty (not a Service or Code module).
    DonManfred likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice