Fabian1648 2 Posted May 29, 2021 (edited) Hello, Is there a solution with FMX to have an events listener that detects all the events that are triggered in an app? Thanks for all Edited May 29, 2021 by Fabian1648 Share this post Link to post
Rollo62 536 Posted May 29, 2021 You could look into TMessage and TMessageManager, which is used internally a lot, but probably not all events. Anyway, you could build something around this, also for custom events, it works quite reliable . Share this post Link to post
Dave Nottage 557 Posted May 30, 2021 On 5/29/2021 at 8:07 PM, Fabian1648 said: Is there a solution with FMX to have an events listener that detects all the events that are triggered in an app? By "events", if you mean things like whether the app became active, entered the background etc, you can have the app subscribe to TApplicationEventMessage: http://docwiki.embarcadero.com/Libraries/Sydney/en/FMX.Platform.TApplicationEventMessage Use TMessageManager to subscribe to the event, e.g: TMessageManager.DefaultManager.SubscribeToMessage(TApplicationEventMessage, ApplicationEventMessageHandler); ..and to unsubscribe when you no longer wish to receive the messages: TMessageManager.DefaultManager.Unsubscribe(TApplicationEventMessage, ApplicationEventMessageHandler); Example handler: procedure TMyClass.ApplicationEventMessageHandler(const Sender: TObject; const M: TMessage); var LMessage: TApplicationEventMessage; begin LMessage := TApplicationEventMessage(M); case LMessage.Value.Event of TApplicationEvent.BecameActive: DoAppBecameActive; TApplicationEvent.EnteredBackground: DoAppEnteredBackground; // etc end; end; 1 2 Share this post Link to post