Java Question #Extends and RaiseEvent

corwin42

Expert
Licensed User
Longtime User
If I use

#Extends: xxx

attribute. Is it possible to raise events?

For example I want to add onDestroy() method. Is it possible to implement onDestroy() to do something like this:

B4X:
    protected void onDestroy() {
        if (processBA.subExists("activity_destroy"))
            processBA.raiseEvent2(null, true, "activity_destroy", false, new Object[0]);

        super.onDestroy();
    }

Problem is how to get a reference to processBA object?
 

corwin42

Expert
Licensed User
Longtime User
You will need to use reflection to get a reference to processBA. Why do you need this event?
It is not really for onDestroy(). That was just an example.

If you remember, early this year we talked about an enhanced menu system with modifyable menus. My final solution was to modify the generated Java code within a #CustomBuildAction.
I just thought if I can do the same with my own Activity class. Main problems seems to be how to raise events from the superclass.

Do you have an example?
 
Top