Magma Expert Licensed User Longtime User Sep 8, 2022 #1 Hi there... I am trying to call a sub from inline java... that works if it is in the same b4xpage... Code: Copy #If JAVA ... public void aaok(byte[] bytes) { _ccallback(bytes); } #END IF public Sub ccallback(bytes111() As Byte) Log(bytes111.Length) end sub but if for example I want the sub in a different b4xpage ... how I will call it ? Someone can tell that I can call it with callsub2 but have in mind that already using Inline JAVA from a different b4xpage (already called java using the following): Code: Copy NativeMe=Main.MainForm NativeMe.InitializeNewInstance("b4j.example.main.myjavaclass", Array(Null)) NativeMe = NativeMe.RunMethod("aaok", Null) 'or with some array - bytes... So is there a command in inline java that will run from a different b4xpage my sub and how i can use them? found ba.raiseEventFromDifferentThread and ba.raiseEventFromUI but how can I use them ???
Hi there... I am trying to call a sub from inline java... that works if it is in the same b4xpage... Code: Copy #If JAVA ... public void aaok(byte[] bytes) { _ccallback(bytes); } #END IF public Sub ccallback(bytes111() As Byte) Log(bytes111.Length) end sub but if for example I want the sub in a different b4xpage ... how I will call it ? Someone can tell that I can call it with callsub2 but have in mind that already using Inline JAVA from a different b4xpage (already called java using the following): Code: Copy NativeMe=Main.MainForm NativeMe.InitializeNewInstance("b4j.example.main.myjavaclass", Array(Null)) NativeMe = NativeMe.RunMethod("aaok", Null) 'or with some array - bytes... So is there a command in inline java that will run from a different b4xpage my sub and how i can use them? found ba.raiseEventFromDifferentThread and ba.raiseEventFromUI but how can I use them ???
Erel B4X founder Staff member Licensed User Longtime User Sep 11, 2022 #2 The correct way to go from native code to B4X code is by raising an event. Example: https://www.b4x.com/android/forum/t...-java-to-b4a-class-module.134605/#post-851691 Upvote 0
The correct way to go from native code to B4X code is by raising an event. Example: https://www.b4x.com/android/forum/t...-java-to-b4a-class-module.134605/#post-851691
Magma Expert Licensed User Longtime User Sep 11, 2022 #3 Ok.. but using this.. getBA().raiseEventFromUI(this, "mysub", values); At "this" ...can I give "the name of different b4xpage mysub inside it" or must be at the same b4xpage.... ??? Upvote 0
Ok.. but using this.. getBA().raiseEventFromUI(this, "mysub", values); At "this" ...can I give "the name of different b4xpage mysub inside it" or must be at the same b4xpage.... ???
Erel B4X founder Staff member Licensed User Longtime User Sep 11, 2022 #4 It is possible with some Java knowledge. You can do it easily from the current B4XPage. Simply delegate the call to whichever page you like. Upvote 0
It is possible with some Java knowledge. You can do it easily from the current B4XPage. Simply delegate the call to whichever page you like.
Magma Expert Licensed User Longtime User Sep 12, 2022 #5 Code: Copy ba.raiseEventFromUI(this, "mysub", myvalues); That worked for me... also call from mysub with callsub2 other b4xpage public sub with passing values and worked ! Upvote 0
Code: Copy ba.raiseEventFromUI(this, "mysub", myvalues); That worked for me... also call from mysub with callsub2 other b4xpage public sub with passing values and worked !