AndroidRegisterLifecycleListener

Typehandler
Dictionarylibrary.androidutils
LibraryAndroid Utilities
Syntax
AndroidRegisterLifecycleListener(<pPauseHandler>,<pResumeHandler>)
Associationscom.livecode.library.androidutils
Summary

Register handlers to be called when on application lifecycle events.

OSandroid
Parameters
NameTypeDescription
pPauseHandler

The handler to be called when the application is paused

pResumeHandler

The handler to be called when the application is resumed

Example
private variable mLifecycleListener as optional JObject

public handler OnOpen() returns nothing
    put AndroidRegisterLifecycleListener(OnMyWidgetPaused, OnMyWidgetResumed) into mLifecycleListener
end handler

public handler OnClose() returns nothing
    AndroidUnregisterLifecycleListener(mLifecycleListener)
    put nothing into mLifecycleListener
end handler

private handler OnMyWidgetPaused() returns nothing
    -- Perform pause actions
end handler

private handler OnMyWidgetResumed() returns nothing
    -- Perform resume actions
end handler
Values
NameTypeDescription
return

A listener object that wraps the registered handlers.

Description

Use the AndroidRegisterLifecycleListener handler to register handlers to application lifecycle events. The handler pPauseHandler will be called when the application is paused and enters into the background. The handler pResumeHandler will be called when the application is resumed and returns from the background.

A listener object will be returned that wraps the registered handlers and can be used with AndroidUnregisterLifecycleListener to cancel the registration.