Java Question How to implement onActivityResult in a wrapper?

Discussion in 'Libraries developers questions' started by DonManfred, Jul 2, 2015.

  1. DonManfred

    DonManfred Expert Licensed User

    Code:
    public void CreatePayment(int amount, String orderID, String description, String emailString bitmap){
            int drawableID = BA.applicationContext.getResources().getIdentifier(
    bitmap"drawable", BA.packageName);
        
    Bitmap image = BitmapFactory.decodeResource(BA.applicationContext.getResources(), drawableID);

        TransactionRequestBuilder builder = new TransactionRequestBuilder(amount, Currency.getInstance(
    "EUR"));
        builder.setDescription(description)
        .setBitmap(
    image);
        
    if (!TextUtils.isEmpty(email)) {
            builder.setEmail(
    email);
        
    }
        TransactionRequest request = builder.createTransactionRequest();
        //PaylevenApi.initiatePayment(this.getParent(), orderID, request);
        PaylevenApi.initiatePayment(ba.activity, orderID, request);
        }
    When executing
    Code:
    PaylevenApi.initiatePayment
    the PayLeven app will be started to handle the Payment.

    The docs saying i must override onActivityResult. I tried different things but i did not got the result returned.


    Code:
    ba.startActivityForResult(ion, intent);
    i cannot use because i dont start any intent. So i cant use ba.startactivityforresult

    Code:
    //@Override
        protected void onActivityResult(int requestCode, int resultCode, 
    Intent data) {
            BA.Log(
    "onActivityResult("+requestCode+","+resultCode);
    is not called.

    When using not "extends Activity" i tried it without the Override.
    I tried it with extends Activity and using Override... Both dont work.

    I dont know what i can try now... Does anybody have a hint for me?
     

    Attached Files:

  2. thedesolatesoul

    thedesolatesoul Expert Licensed User

    This is where inline Java comes into play.

    You can create inline java but dont use override annotation. This will hook up your code to be called before the default onActivityResult is called.
    To be honest I can't remember properly but do have a look at erels inline java tutorial.

    B4A inserts its own code in onavtivtyresult, but it does call super iirc so you can subclass activity as well. Edit. Just read you already tried this.
    BTW also try logging activity.get starting intent in activtyresume.
     
    DonManfred and NJDude like this.
  3. DonManfred

    DonManfred Expert Licensed User

    Thank you for your answer

    Already did this
    Code:
    Sub Activity_Resume
      
    Dim In As Intent
      
    In = Activity.GetStartingIntent
      
    Log(In.HasExtra("result"))
    The output is always false

    I´ll try to implement this with inline java.
     
    lemonisdead likes this.
  4. Erel

    Erel Administrator Staff Member Licensed User

Loading...