Android Question [SOLVED] _onactivityresult, missing Intent data

rosippc64a

Active Member
Licensed User
Longtime User
Hi All,
I have an external aar. I call its function in inline code:
B4X:
 // Start the transaction
MyPOSAPI.openPaymentActivity(ba, payment, 11);
The function works well. I get back the result of this calling, also in inline:
B4X:
public void _onactivityresult(int requestCode,int resultCode){
    BA.Log("_onactivityresult. requestCode: "+requestCode+" resultCode:"+resultCode);
}
,
but I would need the intent data what is sent by this func, so I would need
_onactivityresult(int requestCode,int resultCode,Intent data)
Other words:
The MyPOSAPI.openPaymentActivity(...) doesn't looks like an intent.
I searched for ion, but I can't use for this reason.
Is it a chance to transform my calling ( MyPOSAPI.openPaymentActivity( ...)) into an intent? Whether to wrap into inline java?
thanks
Steven
 
Last edited:

rosippc64a

Active Member
Licensed User
Longtime User
I read all topic deal with this question but I didn't find how I can use the ion in my case.
My problem is that, that I can't convert my inline java calling into an intent, to use the
ba.startActivityForResult(ion, i);
How can I make an intent from this?
B4X:
#if JAVA
...
MyPOSPayment payment = MyPOSPayment.builder()
         // Mandatory parameters
         .productAmount(13.00)
         .currency(Currency.HUF)
         // Foreign transaction ID. Maximum length: 128 characters
         .foreignTransactionId(UUID.randomUUID().toString())
// Start the transaction
MyPOSAPI.openPaymentActivity(ba, payment, 11);
...
#end if
 
Last edited:
Upvote 0

rosippc64a

Active Member
Licensed User
Longtime User
B4X:
     ion = new IOnActivityResult() {
            @Override
            public void ResultArrived(int resultCode, Intent intent) {
                    BA.Log("ResultArrived 1");
                if (resultCode == Activity.RESULT_OK) {
                    BA.Log("ResultArrived");
                }
                ion = null;
            }
        };
    try {
         ba.startActivityForResult(ion, null); //<-- passing null instead of an intent
      } catch (NullPointerException npe) {
         //required...
      }
      BA.SharedProcessBA sba = ba.sharedProcessBA;
      try {
         Field f = BA.SharedProcessBA.class.getDeclaredField("onActivityResultCode");
         f.setAccessible(true);
         int requestCode = f.getInt(sba) - 1;
         //requestCode holds the value that should be used to send the intent.
      } catch (Exception e) {
         throw new RuntimeException(e);
      }
 // Start the transaction
 MyPOSAPI.openPaymentActivity(ba, payment, 11);
Compiling generated Java code. Error
src\b4a\mypos\main.java:1236: error: incompatible types: IOnActivityResult cannot be converted to Intent
ba.startActivityForResult(ion, null); //<-- passing null instead of an intent
 
Upvote 0

rosippc64a

Active Member
Licensed User
Longtime User
No error, no result:
B4X:
 MyPOSPayment payment = MyPOSPayment.builder()
         // Mandatory parameters
         .productAmount(13.00)
         .currency(Currency.HUF)
         // Foreign transaction ID. Maximum length: 128 characters
         .foreignTransactionId(UUID.randomUUID().toString())
         .build();
     ion = new IOnActivityResult() {
            @Override
            public void ResultArrived(int resultCode, Intent intent) {
                    BA.Log("ResultArrived 1");
                if (resultCode == Activity.RESULT_OK) {
                    BA.Log("ResultArrived");
                }
                ion = null;
            }
        };
// Start the transaction
MyPOSAPI.openPaymentActivity(this, payment, 11);
 
Upvote 0

rosippc64a

Active Member
Licensed User
Longtime User
B4X:
    ion = new IOnActivityResult() {
            @Override
            public void ResultArrived(int resultCode, Intent intent) {
                    BA.Log("ResultArrived 1");
                if (resultCode == Activity.RESULT_OK) {
                    BA.Log("ResultArrived");
                }
                ion = null;
            }
        };
    try {
         ba.startActivityForResult(ion, null); //<-- passing null instead of an intent
      } catch (NullPointerException npe) {
         //required...
      }
      BA.SharedProcessBA sba = ba.sharedProcessBA;
      try {
         Field f = BA.SharedProcessBA.class.getDeclaredField("onActivityResultCode");
         f.setAccessible(true);
         int requestCode = f.getInt(sba) - 1;
         //requestCode holds the value that should be used to send the intent.
      } catch (Exception e) {
         throw new RuntimeException(e);
      }
 // Start the transaction
 MyPOSAPI.openPaymentActivity(ba, payment, requestCode);
Compiling generated Java code. Error
src\b4a\mypos\main.java:1236: error: incompatible types: IOnActivityResult cannot be converted to Intent
ba.startActivityForResult(ion, null); //<-- passing null instead of an intent
 
Upvote 0
Top