Android Question Send Intent inside Library

walterf25

Expert
Licensed User
Longtime User
Hi All, i wrapped a library for a client around 1 year ago, ever was working fine until recently, the Device Manufacturer released a new SDK for the device and now some parts are not working anymore.

With the older SDK there was a class that would take care of these Intents, but now with the newer SDK they have included the Class embedded into the SDK.jar file, so I have no control of that class anymore and can not modify it.

Here is the relevant code for one of the specific functions that is no longer working.
Open Admin Menu:
    public void performShowAdminMenu() {
        Intent intent = new Intent("amobilepayment.MENU_ADMIN");
        if (this.mUserDefinedEchoData != null && !this.mUserDefinedEchoData.isEmpty()) {
            intent.putExtra("user_defined_echo_data", this.mUserDefinedEchoData);
        }

        intent.setType("text/plain");
        if (intent.resolveActivity(this.mActivity.getPackageManager()) != null) {
            this.mActivity.startActivityForResult(intent, 8001);
        } else {
           // Toast.makeText(this.mActivity, this.mActivity.getString(string.no_activity_handle), 0).show();
           BA.Log("no activity handle");
        }
    }

As You can see they are just sending an Intent with the "amobilepayment.MENU_ADMIN" string.
And this is the fuction that gets exposed to the library in B4A.
performShowAdminMenu:
private TransactionController mTransactionController;
mTransactionController = TransactionController.getInstance();
mTransactionController.setCallingActivity(mba.activity);
public void performShowAdminMenu(BA ba, boolean AutoPrint) {
        mTransactionController.setAutoPrint(AutoPrint);
        mTransactionController.setUserDefinedEchoData("UPX3456789-123");
        mTransactionController.performShowAdminMenu();
}

I get no errors when i run the code in B4A, i see the Activity_Pause and then Activity_Resume in the logs as if the intent works and tries to launch the Admin Menu window, in the unfiltered logs I see the following:

Any ideas on what may be going on, Like I said this used to work before, the following code is what used to work before the SDK was updated:
Old Function:
    public Intent performShowAdminMenu() {
        Intent intent = new Intent("amobilepayment.MENU_ADMIN");
        if (this.mUserDefinedEchoData != null && !this.mUserDefinedEchoData.isEmpty()) {
            intent.putExtra("user_defined_echo_data", this.mUserDefinedEchoData);
        }

        intent.setType("text/plain");
        //BA.Log("starting Admin Menu: " + this.mActivity.toString());
        return intent;
    }

And the wrapped function in my Library used to look like this:
Java:
    public void performShowAdminMenu(BA ba, boolean AutoPrint) {
        mTransactionController.setAutoPrint(AutoPrint);
       
        mTransactionController.setUserDefinedEchoData("UPX3456789-123");
        final Intent intent = mTransactionController.performShowAdminMenu();
       
          ion = new IOnActivityResult() {
         
          @Override public void ResultArrived(int arg0, Intent arg1) { // TODO
          BA.Log("arg0: " + arg0 + " --- " + "Activity.RESULT_OK: " + Activity.RESULT_OK);
          if (arg0 == Activity.RESULT_OK) {
          IntentWrapper intent2;
          intent2 = new IntentWrapper();
          intent2.setObject(arg1);
          BA.Log("Result code1: " + arg0 + " --- " + Activity.RESULT_OK);
          mba.raiseEventFromUI(this, mEventName + "_resultsarrived", new Object[]{arg0, intent2});
          }else {
          BA.Log("function was not succesful: " + arg0);
          IntentWrapper intent2;
          intent2 = new IntentWrapper();
          intent2.setObject(arg1);
          BA.Log("Result code1: " + arg0 + " --- " + Activity.RESULT_CANCELED);
          mba.raiseEventFromUI(this, mEventName + "_resultsarrived", new Object[] {arg0, intent2});
    }}
};

    ba.startActivityForResult(ion, intent);
       
}

This used to work just fine, but for some reason after them updating the SDK it doesn't work anymore,
I opened their example that comes with the SDK compiled and ran it with Android Studio, and everything works fine there, makes me wonder if there was maybe something that changed in B4A?

I'm supposed to get a -1 in the arg0 but instead I receive a 0.

Any ideas, suggestions, I really need to get this working for my client again.
Thanks,
Walter
 

walterf25

Expert
Licensed User
Longtime User
Why are you making duplicate posts? And in the wrong forum.
Sorry Erel, I thought I would make a more detailed post since I didn't really provide any of the relevant code.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…