Java Question (java) BA.raiseEvent

Mrjoey

Active Member
Licensed User
Longtime User
hello , i need to raise and event on my activity or service , from a java library , i ve seen some threads about it , and i found that u can make it in 2 ways , adding some lines inside the library , or use javaobject , i need some example , simple event with 1 argument or no arguments , tnx
 

Mrjoey

Active Member
Licensed User
Longtime User
i have a this code :
B4X:
    @ShortName("SyncProcess")   
    public static class Syncprocesses{
        public boolean IsEnded = false;
        public BASS.SYNCPROC syncproc = new BASS.SYNCPROC() {
           
            public void SYNCPROC(int handle, int channel, int data, Object user) {
// i need to raise an event from here
                IsEnded = true;
            }
        };
       
    }
can u please tell me what to do and how to implement ba.raseEvent ? thank u
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Something like:
B4X:
@Events(values={"SyncProc(Handle As Int, Channel As Int, Data As Int, User As Object)"})
private BA ba;
private String eventName;
public void Initialize(BA ba, String EventName) {
 this.ba = ba;
 this.eventName = EventName.toLowerCase(BA.cul);
}
...
public void SYNCPROC(...) {
 ba.raiseEvent(null, eventName + "_syncproc", handle, channel, data, user)
}
 

Mrjoey

Active Member
Licensed User
Longtime User
Mr Erel i think u misunderstood my point , i need to raise an event from my java library to b4a activity or process not raising a event to a sub inside the java library.
 

MaFu

Well-Known Member
Licensed User
Longtime User
Mr Erel i think u misunderstood my point , i need to raise an event from my java library to b4a activity or process not raising a event to a sub inside the java library.
This is what Erel's code do.
In the Initialize() function you tell the java lib the event sub name. And then with raiseEvent() you call the B4A event sub.
In your B4A code you must create "Sub eventname_SyncProc(Handle As Int, Channel As Int, Data As Int, User As Object)"
 
Top