Skip to content

Android Activity Lifecycle Hooks

Xed-Editor extensions can hook into the standard Android Activity Lifecycle of the host application. This allows your extension to react when the app is opened, sent to the background, resumed, or completely closed.

Available Methods

kotlin
class Main : ExtensionAPI() {
    override fun onExtensionLoaded(extension: Extension) { }
    override fun onUninstalled(extension: Extension) { }

    override fun afterActivityCreated(activity: Activity) { }
    override fun onActivityResumed(activity: Activity) { }
    override fun onActivityPaused(activity: Activity) { }
    override fun onActivityDestroyed(activity: Activity) { }
}

Lifecycle Reference Table

MethodCalled WhenExtension Receives It?Recommended Use in Extensions
onExtensionLoadedExtension ZIP is first loadedAlways (once per session)Primary initialization – register commands, load settings, start services
onUninstalledUser removes the extension from Xed-EditorYes (if app is running)Final cleanup before extension code is unloaded
onActivityCreatedAny Activity is createdUnknownDo not rely on this – sometimes extensions load after the Activity exists
onActivityResumedApp is in foreground and interactiveYesResume timers, file watchers, network polling, animations
onActivityPausedUser leaves the app (Home, another app, etc.)YesPause timers, animations, release camera/mic, save drafts
onActivityDestroyedAny Activity is permanently destroyedYes (only on real shutdown)cleanup – close DBs, cancel coroutines, unregister receivers

These hooks give you full control over your extension’s behavior in harmony with Xed-Editor’s lifecycle.