Android Question Send Intent inside Library

walterf25

Expert
Licensed 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:
SDKManager initialized....
mSystemManager=com.pos.device.master.ISystemManager$Stub$Proxy@1b8e6dcd
mSystemManager=com.pos.device.master.ISystemManager$Stub$Proxy@1b8e6dcd
WRITE, CONTENT == package_name=com.hidata.traxidriver2
class_name=com.hidata.traxidriver2.Main
NL MSG, len[4015], NL type[0x1C] WNI type[0x5900] len[38671]
NL MSG, PID: 309
START u0 {act=amobilepayment.MENU_ADMIN typ=text/plain cmp=com.amobilepayment.ctpay/.Transactions.ClientIntentHandlerMenuActivity (has extras)} from uid 10117 on display 0
addAppToken: AppWindowToken{3d8ac16c token=Token{12d01a1f ActivityRecord{22f369be u0 com.amobilepayment.ctpay/.Transactions.ClientIntentHandlerMenuActivity t341}}} to stack=1 task=341 at 1
** Activity (main) Pause, UserClosed = false **
FPS: 22
NL MSG, len[4087], NL type[0x1C] WNI type[0x5900] len[57103]
type=1400 audit(0.0:1191): avc: granted { write } for name="launcher_app_info.txt" dev="mmcblk0p32" ino=73779 scontext=u:r:system_app:s0 tcontext=u:eek:bject_r:system_data_file:s0 tclass=file
NL MSG, PID: 309
Display changed displayId=0
NL MSG, len[914], NL type[0x11] WNI type[0x5050] len[894]
NL MSG, PID: 309
Poll result = 1
Found some events!!!
no_seq_check received
event received NL80211_CMD_NEW_SCAN_RESULTS
event received NL80211_CMD_NEW_SCAN_RESULTS, vendor_id = 0x0
event ignored!!
NL MSG, len[4042], NL type[0x1C] WNI type[0x5900] len[45583]
NL MSG, PID: 309
NL MSG, len[3950], NL type[0x1C] WNI type[0x5900] len[22031]
NL MSG, PID: 309
onActivityCreated ClientIntentHandlerMenuActivity
forcedStatusBarColor E
forcedStatusBarColor
Attempt to remove local handle scope entry from IRT, ignoring
Attempt to remove local handle scope entry from IRT, ignoring
Attempt to remove local handle scope entry from IRT, ignoring
Attempt to remove local handle scope entry from IRT, ignoring
Attempt to remove local handle scope entry from IRT, ignoring
Attempt to remove local handle scope entry from IRT, ignoring
Attempt to remove local handle scope entry from IRT, ignoring
Attempt to remove local handle scope entry from IRT, ignoring
Attempt to remove local handle scope entry from IRT, ignoring
Attempt to remove local handle scope entry from IRT, ignoring
Attempt to remove local handle scope entry from IRT, ignoring
Attempt to remove local handle scope entry from IRT, ignoring
** Activity (main) Resume **
Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@8b7335 attribute=null, token = android.os.BinderProxy@2eda645e
Timeline: Activity_idle id: android.os.BinderProxy@21174f5f time:169071570
onActivityDestroyed ClientIntentHandlerMenuActivity

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
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
Top