Menu
Lumberyard
User Guide (Version 1.14)

Process Life Management Gem C++

You can access all system-specific events from C++ (even without enabling the Process Life Management Gem) by connecting to the appropriate EBus. Lumberyard also generates platform-agnostic events so that you can handle these events for all supported platforms.

Lumberyard Application Lifecycle Events

Lumberyard Application Lifecycle Events iOS Android
OnApplicationConstrained applicationWillResignActive onPause()
OnApplicationUnconstrained applicationDidBecomeActive onResume()
OnApplicationSuspended applicationDidEnterBackground onPause()
OnApplicationResumed applicationWillEnterForeground onResume()
OnMobileApplicationWillTerminate applicationWillTerminate onDestroy()
OnMobileApplicationLowMemoryWarning applicationDidReceiveMemoryWarning onLowMemory()

As demonstrated in ProcessLifeManagementGem.h\ProcessLifeManagementGem.cpp, use the following basic steps to receive process lifecycle events in your game.

To receive process lifecycle events in your game

  1. Derive your class from AzFramework::ApplicationLifecycleEvents::Bus::Handler (or AzFramework::[Ios|Android|Windows]LifecycleEvents::Bus::Handler for platform specific events).

  2. Override the functions corresponding to the events that you want to override:

    void OnApplicationConstrained(Event /lastEvent/) override; void OnApplicationUnconstrained(Event /lastEvent/) override; void OnApplicationSuspended(Event /lastEvent/) override; void OnApplicationResumed(Event /lastEvent/) override
  3. Connect to the event bus when you want to start listening for events. In addition, be sure to disconnect when you no longer want to receive them. Use the following syntax:

    ApplicationLifecycleEvents::Bus::Handler::BusConnect(); … ApplicationLifecycleEvents::Bus::Handler::BusDisconnect();