Android Question Serial Connected event dispatch

Alessandro71

Well-Known Member
Licensed User
Longtime User
I'm using a Serial object that I initialize in B4XMainPage_Created sub.
I defined Serial_Connected sub in B4XMainPage also for handling the connected event.
I also have a Serial_Connected sub defined in another B4XPage object, a leftover from previous versions, that I was going to remove.
I observed that the Serial_Connected sub that gets called, is not the one into B4XMainPage, but the one on the topmost page which is shown at connection time.
Since the Initialize sub of the Serial object does not include a "parent" object parameter for the connected event, how are event subs dispatched?
How do I make sure the called _Connected sub is the one from in the MainPage?
 

Alessandro71

Well-Known Member
Licensed User
Longtime User
An update with more findings:
It looks like the _Connected sub that is called is the one in the same object where the Connect sub where called from, that can be different from the one where the Initialize sub was initially called
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
It looks like the _Connected sub that is called is the one in the same object where the Connect sub where called from, that can be different from the one where the Initialize sub was initially called
That is correct. The Connected event will be raised in the class or Activity that called Connect. It will run on the main thread of your app.
 
Upvote 1
Top