Java Question IOnActivityResult - my own requestcode

rosippc64a

Active Member
Licensed User
Longtime User
Hi All,
I use the ionactivityresult with success, but now I should like to add my own requestcode.
B4X:
         ion = new IOnActivityResult() {
            @Override
            public void ResultArrived(int resultCode, Intent data) {           
                pResultArrived("storenewcard", resultCode, data);
            };
        };
        BA.Log("myPOSStoreNewCard 5");
        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);
             requestCode = f.getInt(sba) - 1;
             //requestCode holds the value that should be used to send the intent.
          } catch (Exception e) {
             throw new RuntimeException(e);
          }   
        ba.startActivityForResult(ion, intent);
        //startActivityForResult(intent, MyPos.REQUEST_CODE_STORE_CARD); <--this should be done
Is it possible?
Thanks
Steven
 

rosippc64a

Active Member
Licensed User
Longtime User
Thanks for the reply @Erel
I have to start a class, the whole code is here:
B4X:
   public void myPOSStoreNewCard(BA ba){
        int requestCode;
        xba = ba;
        MyPos myPos = MyPos.getInstance();
        myPos.init(
                Utils.MYPOS_SID,
                Utils.MYPOS_WALLET_NUMBER,
                Utils.CURRENCY,
                Utils.CLIENT_PRIVATE_KEY,
                Utils.SERVER_PUBLIC_KEY,
                Utils.isSandbox
        );
        myPos.setKeyIndex(Utils.KEY_INDEX);
        myPos.setLanguage(Utils.LANGUAGE);
        Intent intent = new Intent(ba.context, StoreCardActivity.class);
        intent.putExtra(MyPos.INTENT_EXTRA_VERIFICATION_AMOUNT, Utils.VERIFICATION_AMOUNT);
         ion = new IOnActivityResult() {
            @Override
            public void ResultArrived(int resultCode, Intent data) {           
                pResultArrived("storenewcard", resultCode, data);
            };
        };
        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);
             requestCode = f.getInt(sba) - 1;
             //requestCode holds the value that should be used to send the intent.
          } catch (Exception e) {
             throw new RuntimeException(e);
          }   
        ba.startActivityForResult(ion, intent);
        //startActivityForResult(intent, MyPos.REQUEST_CODE_STORE_CARD);
    }
 
Top