Missed the live Ionic Event? Check out all the product announcements, new releases, and more.

DocsPluginsCLI

Capacitor Android API

Capacitor Android is the native runtime that powers Capacitor apps on Android.

🚧 This guide is a work-in-progress. Thanks for your patience!


Saving PluginCall

Notes on persisting plugin calls for asynchronous or repeated operations can be found here.


Bridge

The Android bridge is the heart of the Capacitor Android library. There are several methods available on the bridge which provide information or change behavior.

When registered with Capacitor, plugins have access to the bridge:

this.bridge

getConfig()

public CapConfig getConfig()

This property contains the configuration object known to the Capacitor runtime.


triggerJSEvent(…)

public void triggerJSEvent(final String eventName, final String target)
public void triggerJSEvent(final String eventName, final String target, final String data)

Fire an event on a JavaScript EventTarget such as window or document. If possible, it is preferred to use Plugin Events instead.

Examples:

bridge.triggerJSEvent("myCustomEvent", "window");
bridge.triggerJSEvent("myCustomEvent", "document", "{ 'dataKey': 'dataValue' }");
Contribute ->