tencent cloud

Feedback

Other Mini Program APIs

Last updated: 2024-03-04 22:47:34

    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

    /**
    * Terminate Mini Program
    *
    * @param context
    * @param appId
    */
    public static void stopMiniApp(Context context, String appId)
    /**
    * Terminate All Mini Programs
    *
    * @param context Context
    */
    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
    /**
    * Call the Mini Program process plugin (call the official version of the Mini Program). This method can only be called in the main process
    *
    * @param appId Mini Program ID
    * @param eventId
    * @param request
    * @param callback
    */
    public static void callMiniProcessPlugin(String appId, String eventId, Bundle request, IpcCallback callback)
    /**
    * Call the Mini Program process plugin (call the preview version of the Mini Program). This method can only be called in the main process
    *
    * @param appId Mini Program ID
    * @param appVerType: The type of the Mini Program. See MiniApp for details.
    * @param eventId
    * @param request
    * @param 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
    /**
    * Call the main process Plugin. This method can only be called within the Mini Program process
    *
    * @param eventId
    * @param request
    * @param callback
    */
    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

    /** * Pre-download Mini Program Main Package
    /** * @param preDownloadInfo Information for Pre-download * @param callback Download Callback */ public static void preDownloadPkg(PreDownloadInfo preDownloadInfo, IDownloadCallback callback)
    /** * Pre-download Mini Program Main Package * @param preDownloadInfos Information for Pre-download * @param callback Download Callback */ public static void preDownloadPkg(List<PreDownloadInfo> preDownloadInfos, IDownloadCallback callback)
    
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support