Acquire the Recent List of Visited Mini Programs
/**
* Acquire the recent list of visited Mini Programs
* @param callback
*/
public static void getRecentList(IRecentMiniCallback callback)
Search for Official Mini Programs
/**
* Mini Program Search
*
* @param searchOptions
* @param callback
*/
public static void searchMiniApp(SearchOptions searchOptions, MiniCallback<List<MiniApp>> callback)
Is the Current Process a Mini Program Process?
/**
Is the Currently Running Process a Mini Program Process?
* @param context
* @return
*/
public static boolean isMiniProcess(Context context)
Terminate Mini Program
public static void stopMiniApp(Context context, String appId)
public static void stopAllMiniApp(Context context)
Main Process Calling Mini Program Process Plugin
Define Subprocess Plugin
@IpcMiniPlugin
public class MiniProcessIpcPlugin extends BaseIpcPlugin {
public static final String EVENT = "MiniProcessPlugin";
@Override
@IpcEvent(EVENT)
public void invoke(IpcRequestEvent req) {
String value = req.data.getString("key");
Log.d(ModuleApplet.TAG, "current process:" + ProcessUtil.getProcessName(req.context) + "|call from main process: " + value);
Bundle resp = new Bundle();
resp.putString("key", "i am ok");
req.ok(resp);
}
}
Inherit BaseIpcPlugin
Decorate the defined class with the annotation @IpcMiniPlugin
Use the Annotation @IpcEvent to decorate the Invoke method, and define the plugin event name.
Call Plugin in Main Process
public static void callMiniProcessPlugin(String appId, String eventId, Bundle request, IpcCallback callback)
public static void callMiniProcessPlugin(String appId, int appVerType, String eventId, Bundle request, IpcCallback callback)
Example:
TmfMiniSDK.callMiniProcessPlugin("", MiniProcessIpcPlugin.EVENT, bundle, new IpcCallback() {
@Override
public void result(boolean isSucc, Bundle response) {
Log.d(ModuleApplet.TAG, "current process:" + ProcessUtil.getProcessName(ModuleApplet.sApp) + "|isSucc:" + isSucc + "|callback data:" + response.getString("key"));
}
});
Mini Program Process Calling Main Process Plugin
Define Main Process Plugin
@IpcMainPlugin
public class MainProcessIpcPlugin extends BaseIpcPlugin {
public static final String EVENT = "MainProcessPlugin";
@Override
@IpcEvent(EVENT)
public void invoke(IpcRequestEvent req) {
String value = req.data.getString("key");
Log.d(ModuleApplet.TAG, "current process|" + ProcessUtil.getProcessName(req.context) + "|call from mini process:" + value);
Bundle resp = new Bundle();
resp.putString("key", "i am ok");
req.ok(resp);
}
}
Inherit BaseIpcPlugin
Decorate the defined class with the annotation @IpcMainPlugin
Use the Annotation @IpcEvent to decorate the Invoke method, and define the plugin event name.
Calling Plugin within Mini Program Process
public static void callMainProcessPlugin(String eventId, Bundle request, IpcCallback callback)
Example:
TmfMiniSDK.callMainProcessPlugin(MainProcessIpcPlugin.EVENT, bundle, new IpcCallback() {
@Override
public void result(boolean isSucc, Bundle response) {
Log.d(ModuleApplet.TAG, "current process:" + ProcessUtil.getProcessName(ModuleApplet.sApp) + "|isSucc:" + isSucc + "|callback data:" + response.getString("key"));
}
});
Pre-download Mini Program
public static void preDownloadPkg(PreDownloadInfo preDownloadInfo, IDownloadCallback callback)
public static void preDownloadPkg(List<PreDownloadInfo> preDownloadInfos, IDownloadCallback callback)
Was this page helpful?