All Products
Search
Document Center

Mobile Platform as a Service:Manage HTML5 pages

Last Updated:Jan 26, 2026

After you open an HTML5 offline package, you can embed a container view into a native page using a synchronous or asynchronous method.

Note

Asynchronous methods do not use the main thread and do not affect performance.

  • To embed a container view into a native page using a synchronous method:

    public static final void openH5(String url) {
        if (TextUtils.isEmpty(url)) {
            return;
        }
        H5Service h5Service = LauncherApplicationAgent.getInstance().getMicroApplicationContext()
                .findServiceByInterface(H5Service.class.getName());
        H5Bundle bundle = new H5Bundle();
        Bundle param = new Bundle();
        // The appId of the offline package to open.
        param.putString(H5Param.APP_ID, appId);
        // The URL within the offline package to open, such as /www/index.html. The leading slash (/) is required.
        // If you do not pass a URL, the container opens the default URL configured for the offline package.
        param.putString(H5Param.LONG_URL,url);
        bundle.setParams(param);
        if (h5Service != null) {
            H5Page h5Page=h5Service.createPage(activity,bundle);
          View view=h5Page.getContentView(),
         // Finally, add the view to your page.
        }
    }
  • To embed a container view into a native page using an asynchronous method:

    H5Service h5Service = LauncherApplicationAgent.getInstance().getMicroApplicationContext()
                      .findServiceByInterface(H5Service.class.getName());
    H5Bundle bundle = new H5Bundle();
    Bundle param = new Bundle();
         param.putString(H5Param.APP_ID, appId);
         param.putString(H5Param.LONG_URL, url);
         bundle.setParams(param);
         if (h5Service != null) {
                 h5Service.createPageAsync(activity, bundle, h5PageReadyListener);
         }