Android Question Get Value from Inline Java

MarcoRome

Expert
Licensed User
Longtime User
Hi @Erel, All.
To fetch values from inline JAVACODE and insert such as a label or in a variable.
Example i have this code in B4A:

B4X:
...
Ritorno = jo2.RunMethod("Coffe",Array(1))
....

and this return me more value ( loop in notifyMessage(ret)) that i see in Log window becuase i add into code BA.Log(value);

This Code Inline JavaCode:
B4X:
......
public void handleMessage(Message msg) {
Bundle bundle = msg.getData();
     if(bundle.containsKey(IrHandler.MSG_VERSION_STRING)) {
                 BA.Log("QUI");
                String value = bundle.getString(IrHandler.MSG_VERSION_STRING);
                BA.Log("QUI1");
                BA.Log(value);
            }
            if(bundle.containsKey(IrHandler.MSG_SN_STRING)) {
                String value = bundle.getString(IrHandler.MSG_SN_STRING);
                BA.Log(value);
            }
            if(bundle.containsKey(IrHandler.MSG_BATTERY_INT)) {
                int value = bundle.getInt(IrHandler.MSG_BATTERY_INT);
                BA.Log("** Battery: " + String.format("%X", value));
            }
.....

The same value that i see in Log windows i have to get to insert themselves in a label.
Thank you
Marco
 

DonManfred

Expert
Licensed User
Longtime User
I suggest to raise an event in B4A from inside the handleMessage giving the actual value in this event....
Or use a (inline java global) List and fill this list from handleMessage... After work you get the global list with a getter for ex.
 
Upvote 0

MarcoRome

Expert
Licensed User
Longtime User
Hi Great Don. Thank you for your answer.
I didnt understand how to implement what you say. You can make a small example ??
Keep in mind that the Value:
B4X:
....
if(bundle.containsKey(IrHandler.MSG_SN_STRING)) {
                String value = bundle.getString(IrHandler.MSG_SN_STRING);
                BA.Log(value);
            }
.....
variable is updated continuously, until will found the value.
Thank you very much
 
Upvote 0
Top