For AI agents: the complete documentation index is available at /next/llms.txt, the full documentation bundle is available at /next/llms-full.txt, and this page is available as Markdown at /next/api/lynx-native-api/lynx-extension-module/on-enter-foreground.md.
Lynx
  • English
  • OnEnterForeground

    OnEnterForeground is a virtual lifecycle method in the LynxExtensionModule class. It is called by the Lynx framework when the host application transitions from the background to the foreground.

    This callback is always invoked on the UI thread. It is useful for resuming activities, restarting animations, or refreshing data that may have been paused or become stale while the application was in the background.

    Method Signature

    virtual void OnEnterForeground();

    Usage

    Override this method in your LynxExtensionModule subclass to handle application foregrounding events. For instance, you could resume a video, restart a WebSocket connection, or trigger a data refresh.

    Example

    #include "lynx_extension_module.h"
    
    class MyMediaModule : public lynx::pub::LynxExtensionModule {
    public:
        void OnEnterForeground() override {
            // Application has entered the foreground.
            printf("MyMediaModule: Resuming activities.\\n");
    
            // Example: Post a task to the BTS thread to resume a video player.
            PostTaskToRuntime([]() {
                // videoPlayer->resume();
            });
        }
    
        void OnEnterBackground() override {
            // Application has entered the background.
            printf("MyMediaModule: Pausing activities.\\n");
    
            // Example: Post a task to pause the video player.
            PostTaskToRuntime([]() {
                // videoPlayer->pause();
            });
        }
    
        // ... other lifecycle methods
    };

    See Also

    • OnEnterBackground(): The counterpart to this method, called when the application enters the background.

    Compatibility

    LCD tables only load in the browser

    Except as otherwise noted, this work is licensed under a Creative Commons Attribution 4.0 International License, and code samples are licensed under the Apache License 2.0.