This article describes how to implement the launch of Mini Program functionality in Android mobile applications.
1. Multi-Platform Application Development Guide
To reduce the development cost for building mobile applications, the platform has introduced a multi-platform framework based on Mini Program technology. This framework allows for cost-effective development of Android and iOS applications. For more details, see Overview of the Multi-Platform Framework. If your App is developed using the official multi-platform framework, you can invoke the following JSAPI to launch Mini Program functionality within your App:
2. Non-Cross-Platform App Development Guide
If your App is not developed using a cross-platform framework, you can follow the guide below to integrate the WeChat SDK into your App and then call the API to launch a Mini Program. Before development, you need to download the Android Software Development Kit (SDK). You can download it here.
API to Call: WXLaunchMiniProgram
Example of jumping from a Mobile App to a Mini Program:
String appId = "wxd930ea5d5a258f4f"; // Fill in the AppId of the Mobile App (App), not the AppID of the Mini Program
IWXAPI api = WXAPIFactory.createWXAPI(context, appId);
WXLaunchMiniProgram.Req req = new WXLaunchMiniProgram.Req();
req.userName = "gh_d43f693ca31f"; // Fill in the original ID of the Mini Program
req.path = path; // The path to launch a specific page of the Mini Program with parameters. If left blank, it defaults to the home page of the Mini Program.
// For Mini Games, you can pass only the query part to achieve parameter passing, e.g., passing "?foo=bar"
req.miniprogramType = WXLaunchMiniProgram.Req.MINIPTOGRAM_TYPE_RELEASE; // Optional: specify whether to open the development version, trial version, or release version
api.sendReq(req);
Callback Description
In WXEntryActivity:
public void onResp(BaseResp resp) {
if (resp.getType() == ConstantsAPI.COMMAND_LAUNCH_WX_MINIPROGRAM) {
WXLaunchMiniProgram.Resp launchMiniProResp = (WXLaunchMiniProgram.Resp) resp;
String extraData = launchMiniProResp.extMsg; // Corresponds to the app-parameter attribute in the <button open-type="launchApp"> component of the Mini Program
}
}
For jumping from a Mini Program back to a Mobile App, please refer to the " Mini Program Development Documentation".