PortalFragment
The PortalFragment class is an Android Fragment containing a Portal instance. You can use the class as is, or extend it to provide customizable loading functionality.
Because PortalFragment is an extended Fragment class, you can override the following Fragment functions:
onViewCreated
onDestroy
onResume
onPause
onConfigurationChanged
Constructors
constructor
Usage
- Kotlin
- Java
val fragment: PortalFragment = PortalFragment()
PortalFragment fragment = new PortalFragment();
Additionally, you can pass in an already initialized Portal instance to a new PortalFragment
- Kotlin
- Java
val portal: Portal = someValue
val fragment: PortalFragment = PortalFragment(portal)
Portal portal = someValue;
PortalFragment fragment = new PortalFragment(portal);
Parameters
Name | Type | Description |
---|---|---|
portal | Portal | An initialized Portal object to contain within the PortalFragment |
Returns: PortalFragment
Methods
addPlugin
Add a Plugin to the Portal within PortalFragment
Usage
- Kotlin
- Java
val fragment: PortalFragment = PortalFragment()
fragment.addPlugin(MyPlugin::class.java)
PortalFragment fragment = new PortalFragment();
fragment.addPlugin(MyPlugin.class);
Parameters
Name | Type | Description |
---|---|---|
plugin | Class<out Plugin?> | The Capacitor Plugin class to add to your Portal |
setConfig
Set a CapConfig
configuration object to this PortalFragment
Usage
- Kotlin
- Java
val fragment: PortalFragment = PortalFragment()
val config: CapConfig = someValue;
fragment.setConfig(config)
PortalFragment fragment = new PortalFragment();
CapConfig config = someValue;
fragment.setConfig(config);
Parameters
Name | Type | Description |
---|---|---|
config | CapConfig | The Capacitor CapConfig class to add to your Portal |
getBridge
Returns the Capacitor Bridge
object connected to the PortalFragment.
Usage
- Kotlin
- Java
val fragment: PortalFragment = PortalFragment()
val bridge: Bridge = fragment.getBridge()
PortalFragment fragment = new PortalFragment();
Bridge bridge = fragment.getBridge();
Returns: Bridge
addWebViewListener
Add a WebViewListener
instance to the PortalFragment to listen for web events.
Usage
- Kotlin
- Java
val fragment: PortalFragment = PortalFragment()
val listener: WebViewListener = someValue;
fragment.addWebViewListener(listener)
PortalFragment fragment = new PortalFragment();
WebViewListener listener = someValue;
fragment.addWebViewListener(listener);
Parameters
Name | Type | Description |
---|---|---|
webViewListener | WebViewListener | The Capacitor WebViewListener class that you can use to listen to web loading events. |
linkMessageReceivers
Link a class with methods decorated with the @PortalMethod annotation to use as Portals message receivers.
The name of the method should match the message name used to send messages via the Portal. Alternatively the @PortalMethod annotation name property can be used to designate a different name. The registered methods should accept a single String representing the payload of a message sent through the Portal.
Usage
- Kotlin
- Java
val fragment: PortalFragment = PortalFragment()
fragment.linkMessageReceivers(this)
PortalFragment fragment = new PortalFragment();
fragment.linkMessageReceivers(this);
Parameters
Name | Type | Description |
---|---|---|
messageReceiverParent | Any | The parent object of the message receivers. This value will almost always be this . |