Android Question Call a b4a function from java jar library

xXswetXx19

New Member
I have a APP in b4a with a list that i want to fill each time that a listener in my jar library is triggered, for this i want to call a function in my b4a code from the jar library, i tried too many ways but it didnt work, can you help me? (Sorry my english)

The jar is the comunication module from a barcode reader with the APP, and i have a class in the jar that executes each time a barcode is readed, so i want addd the code to the list in my b4a app.
 

aeric

Expert
Licensed User
Longtime User
You should post your error and sample project. No one can see your code to know what's wrong.

 
Upvote 0

agraham

Expert
Licensed User
Longtime User
This sort of how my Basic interpreter library calls back into B4A code. I have simplified the code to omit some threading logic as you don't need that so I might have unwittingly introduced some errors.

Java:
private String callhostsub(BA processBA, String sub, Object[] args)
{
        try
        {
            sub = sub.toLowerCase();
            if (args == null)
                args = new String[0];
            if (!BA.subExists(sub))
            {
                BA.Log("B4A", "CallHostSub :  Sub " + sub + " not found!");
                return "";
            }
            String ret;  
            // use raiseEvent2 to let it run during Activity_Create
            ret = (String) BA.raiseEvent2(this, true, sub, false, args);
            // raiseEvent returns null during Activity_Create
            if (ret == null)
            {
        ret = "";
            }
      return ret;
        } catch (Exception e)
        {
            String msg = "CallHostSub : " + sub + " - " + e.toString() + " - " + e.getMessage();
            BA.Log( msg);
        }
        return "";
    }
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…