上次更新时间:2026年10月5日
App Lifecycle
Monitor and respond to app lifecycle events such as foreground, background, and exit attempts.
TT.GetAppLifeCycle()
Returns the current application lifecycle state.
Signature
public static string GetAppLifeCycle()Returns
Type | Description |
| Current lifecycle state (e.g., |
TT.SetOnBeforeExitAppListener(callback)
Registers a listener that is invoked before the app exits. The callback can influence whether the exit proceeds.
Signature
public static void SetOnBeforeExitAppListener(Action<BeforeExitAppParam> callback)Parameters
Field | Type | Description | Required |
|
| Callback invoked before exit. | Yes |
Example
TT.SetOnBeforeExitAppListener(param =>
{
// Set cancel to true to prevent the app from exiting
param.cancel = true;
Debug.Log("Exit prevented by listener");
});