Java Question How to implement onActivityResult in a wrapper?

DonManfred

Expert
Licensed User
B4X:
    public void CreatePayment(int amount, String orderID, String description, String email, String 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
B4X:
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.


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

B4X:
    //@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?
 

Attachments

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

Expert
Licensed User
Thank you for your answer

BTW also try logging activity.get starting intent in activtyresume.
Already did this
B4X:
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.
 
Top