Appearance
Other
1. Set the switching animation of the Activity of the mini program
API
kotlin
/**
* Set the toggle animation of the mini program Activity
*
* @param anim [Anim] animation
*/
fun setActivityTransitionAnim(anim: Anim)
Example of a call to ####
kotlin
FinAppClient.appletApiManager.setActivityTransitionAnim(SlideFromRightToLeftAnim)
java
FinAppClient.INSTANCE.getAppletApiManager().setActivityTransitionAnim(SlideFromRightToLeftAnim.INSTANCE);
2. Send events to mini program natively
API
kotlin
/**
* Send events to mini program natively
* @param appId
* @param params event parameters
*/
fun sendCustomEvent(appId: String, params: String)
Call example
kotlin
FinAppClient.appletApiManager.sendCustomEvent("app", "{\"test\":\"123\"}")
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 useFinAppletWebView
, 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
kotlin
val finAppletWebView = FinAppClient.appletApiManager.createFinAppletWebView(this)
java
FinAppletWebView finAppletWebView = FinAppClient.INSTANCE.getAppletApiManager().createFinAppletWebView(context);
4. Calling interfaces across processes
4.1 Calling mini program 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 mini program process parameters",
object : FinCallback<String> {
override fun onSuccess(result: String?) {
toast("The result returned by the mini program process: $result")
}
override fun onError(code: Int, error: String?) {
}
override fun onProgress(status: Int, info: String?) {
}
})
Receive Need to register a handler with the mini program process Can be determined by ``FinAppClient.isFinAppProcess(context)` if it is an mini program 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 mini program process: name:$name,params:$params")
callback?.onSuccess("Returning results to the main process")
}
})
}
4.2 Calling the main process from an mini program process
The call needs to be made in the mini program process
kotlin
FinAppProcessClient.appletProcessApiManager.callInMainProcess(
"Name of the method by which the mini program process calls the main process",
"Parameters for the mini program process to call the main process",
object : FinCallback<String> {
override fun onSuccess(result: String?) {
toast("The mini program 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("mini program process calling main process: name:$name,params:$params")
callback?.onSuccess("Returning results to the mini program process")
}
})
5. call api in mini program process
FinAppClient.appletApiManager
can only be used in the main process
The methods in FinAppProcessClient.appletProcessApiManager
are to be used in the mini program process.
For example
kotlin
FinAppProcessClient.appletProcessApiManager.getCurrentAppletId()
FinAppProcessClient.appletProcessApiManager.getAppletInfo()
FinAppProcessClient.appletProcessApiManager.sendCustomEvent(params)
_ Translated with www.DeepL.com/Translator (free version) _