Skip to content

Other

1. Set the switching animation of the Activity of the applet

API

kotlin
/**
 * Set the toggle animation of the applet Activity
 *
 * @param anim [Anim] animation
 */
fun setActivityTransitionAnim(anim: Anim)

Example of a call to #### :::: tabs ::: tab "Kotlin"

kotlin
FinAppClient.appletApiManager.setActivityTransitionAnim(SlideFromRightToLeftAnim)

:::

::: tab "Java"

java
FinAppClient.INSTANCE.getAppletApiManager().setActivityTransitionAnim(SlideFromRightToLeftAnim.INSTANCE);

::: ::::

2. Send events to applets natively

API

kotlin
/**
 * Send events to applets natively
 * @param appId
 * @param params event parameters
 */
fun sendCustomEvent(appId: String, params: String)

Call example

:::: tabs ::: tab "Kotlin"

kotlin
FinAppClient.appletApiManager.sendCustomEvent("app", "{\"test\":\"123\"}")

:::

::: tab "Java"

java
FinAppClient.INSTANCE.getAppletApiManager().sendCustomEvent("app", "{\"test\":\"123\"}")")

::: ::::

3. Create a [FinAppletWebView] instance

This method is deprecated as of 2.12.4. If you need to use FinAppletWebView, just instantiate the class.

API

kotlin
/**
 * Create a [FinAppletWebView] instance
 *
 * @param context [Context] object
 * @return a [FinAppletWebView] instance
 */
fun createFinAppletWebView(context: Context): FinAppletWebView

call example

:::: tabs ::: tab "Kotlin"

kotlin
val finAppletWebView = FinAppClient.appletApiManager.createFinAppletWebView(this)

:::

::: tab "Java"

java
FinAppletWebView finAppletWebView = FinAppClient.INSTANCE.getAppletApiManager().createFinAppletWebView(context);

::: ::::

4. Calling interfaces across processes

4.1 Calling applet processes from the main process

The call needs to be made in the main process

kotlin
FinAppClient.appletApiManager.callInAppletProcess(
        FinAppClient.appletApiManager.getCurrentAppletId().orEmpty(),
        "Name of the method by which the main process calls the applet process",
        "Main process calling applet process parameters",
        object : FinCallback<String> {
            override fun onSuccess(result: String?) {
                toast("The result returned by the applet process: $result")
            }

            override fun onError(code: Int, error: String?) {

            }

            override fun onProgress(status: Int, info: String?) {

            }
        })

Receive Need to register a handler with the applet process Can be determined by FinAppClient.isFinAppProcess(context) if it is an applet process

kotlin
if (FinAppClient.isFinAppProcess(this)) {
    FinAppProcessClient.appletProcessApiManager.setMainProcessCallHandler(
        object : IAppletProcessApiManager.MainProcessCallHandler {
            override fun onMainProcessCall(
                name: String,
                params: String?
                callback: IApiCallback?
            ) {
                toast("Main process calling applet process: name:$name,params:$params")
                callback?.onSuccess("Returning results to the main process")
            }
        })
}

4.2 Calling the main process from an applet process

The call needs to be made in the applet process

kotlin
FinAppProcessClient.appletProcessApiManager.callInMainProcess(
    "Name of the method by which the applet process calls the main process",
    "Parameters for the applet process to call the main process",
    object : FinCallback<String> {
        override fun onSuccess(result: String?) {
            toast("The applet process called the main process successfully: $result")
        }

        override fun onError(code: Int, error: String?) {

        }

        override fun onProgress(status: Int, info: String?) {

        }
    })

Receive Handler method needs to be registered with the main process

kotlin
FinAppClient.appletApiManager.setAppletProcessCallHandler(
    object : IAppletApiManager.AppletProcessCallHandler {
        override fun onAppletProcessCall(
            name: String,
            params: String?
            callback: IApiCallback?
        ) {
            application.toast("Applet process calling main process: name:$name,params:$params")
            callback?.onSuccess("Returning results to the applet process")
        }
    })

5. call api in applet process

FinAppClient.appletApiManager can only be used in the main process

The methods in FinAppProcessClient.appletProcessApiManager are to be used in the applet process.

For example

kotlin
 FinAppProcessClient.appletProcessApiManager.getCurrentAppletId()

 FinAppProcessClient.appletProcessApiManager.getAppletInfo()

 FinAppProcessClient.appletProcessApiManager.sendCustomEvent(params)

*** Translated with www.DeepL.com/Translator (free version) ***