Entry Class and Extension Context
Every Xed-Editor extension is executed through a single entry class, usually named Main. This is the class that you previously specified in the manifest.
This class is the runtime bridge between your extension and the host system.
Role of the Entry Class
The entry class serves as the starting point for your extension. It defines all lifecycle callbacks, as you learned on the previous page.
Furthermore, it has access to the extension context and much more, which we will cover later.
It is instantiated by Xed-Editor when the extension is loaded.
Required Structure
@Keep
@Suppress("unused")
class Main(context: ExtensionContext) : ExtensionAPI(context) {
override fun onExtensionLoaded() {}
override fun onUninstalled() {}
override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {}
override fun onActivityResumed(activity: Activity) {}
override fun onActivityPaused(activity: Activity) {}
override fun onActivityDestroyed(activity: Activity) {}
} ExtensionAPI inheritance
Your main entry class must inherit from ExtensionAPI. ExtensionAPI is an abstract base class that implements Application.ActivityLifecycleCallbacks, which is how the host application forwards Android lifecycle events into your extension.
The host application instantiates your entry class and forwards lifecycle events to it automatically.
Extension Context
Each extension receives an ExtensionContext instance as a constructor parameter in its main class.
It works similarly to the Android Context, but is scoped to the extension and provides access to extension-specific resources and host integration features.
This context is passed into ExtensionAPI, making it available throughout the main entry class.
It currently provides access to:
extension→ metadata and runtime representation of the loaded extension (e.g. id, apk file, version)hostContext→ the original Android application context provided by Xed-Editorsettings→ persistent key-value storage scoped to the extensionassets→ access to the extension APK assetsresources→ access to the extension APK resources
Annotations
These annotations are required for correct runtime behavior.
@Keep
Prevents Android build tools (R8 / ProGuard) from removing or renaming the class.
Xed-Editor loads extensions dynamically using reflection, so the class name must remain unchanged.
@Suppress("unused")
Suppresses compiler warnings for the entry class being reported as unused.
The entry class is invoked by Xed-Editor at runtime, so it is not referenced directly in your code.