corwin42 Expert Licensed User Longtime User Nov 3, 2014 #1 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: Code: Copy 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?
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: Code: Copy 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?
Erel B4X founder Staff member Licensed User Longtime User Nov 3, 2014 #2 You will need to use reflection to get a reference to processBA. Why do you need this event?
corwin42 Expert Licensed User Longtime User Nov 3, 2014 #3 Erel said: You will need to use reflection to get a reference to processBA. Why do you need this event? Click to expand... 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?
Erel said: You will need to use reflection to get a reference to processBA. Why do you need this event? Click to expand... 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?
Erel B4X founder Staff member Licensed User Longtime User Nov 3, 2014 #4 Try this: BA pba = this.getClass().getField("processBA").get(null);