All Products
Search
Document Center

10.1.68

Last Updated: Feb 20, 2021

This topic describes the API operations for the Android HTML5 container and offline package SDKs in mPaaS 10.1.68.

Common functions

H5TitleView

getTitle

  • Declaration
    String getTitle();
  • Description
    Queries the text of the main title.
  • Parameters
    None.
  • Returned value
    The value is the main title of the STRING type.

setTitle

  • Declaration
    void setTitle(String title);
  • Description
    Sets the text of the main title.
  • Parameters
Parameters Data type Description
title String Title text
  • Returned value
    None.

setSubTitle

  • Declaration
    void setSubTitle(String subTitle);
  • Description
    Sets the subtitle.
  • Parameters
Parameters Data type Description
subTitle String The text of the subtitle.
  • Returned value
    None.

setImgTitle

  • Declaration
    void setImgTitle(Bitmap imgTitle);
  • Description
    Sets the image icon of the title.
  • Parameters
Parameters Data type Description
imgTitle Bitmap The information about the image icon.
  • Returned value
    None.

setImgTitle

  • Declaration
    void setImgTitle(Bitmap imgTitle,String contentDescription);
  • Description
    Sets the image icon and content description of the title.
  • Parameters
Parameters Data type Description
imgTitle Bitmap The information about the image icon.
contentDescription String The content description of the title.
  • Returned value
    None.

showCloseButton

  • Declaration
    void showCloseButton(boolean visible);
  • Description
    Specifies whether to show the Close button.
  • Parameters
Parameters Data type Description
visible boolean Specifies whether to show the Close button. Valid values: true: Shows the Close button.
false: Hides the Close button.
  • Returned value
    None.

getContentView

  • Declaration
    View getContentView();
  • Description
    Queries the view of the title bar.
  • Parameters
    None.
  • Returned value
    View: the view of the title bar.

getContentBgView

  • Declaration
    ColorDrawable getContentBgView();
  • Description
    Queries the background of the title bar.
  • Parameters
    None.
  • Returned value
    ColorDrawable: the background of the title bar.

getMainTitleView

  • Declaration
    TextView getMainTitleView();
  • Description
    Queries the view of the main title.
  • Parameters
    None.
  • Returned value
    TextView: the view of the main title.

getSubTitleView

  • Declaration
    TextView getSubTitleView();
  • Description
    Queries the view of the subtitle.
  • Parameters
    None.
  • Returned value
    TextView: the view of the subtitle.

showBackButton

  • Declaration
    void showBackButton(boolean visible);
  • Description
    Specifies whether to show the Back button.
  • Parameters
Parameters Data type Description
visible boolean Valid values: true: Shows the Back button.
false: Hides the Back button.
  • Returned value
    None.

showBackHome

  • Declaration
    void showBackHome(boolean visible);
  • Description
    Specifies whether to show the Home button.
  • Parameters
Parameters Data type Description
visible boolean Valid values: true: Shows the Back button.
false: Hides the Back button.
  • Returned value
    None.

showOptionMenu

  • Declaration
    void showOptionMenu(boolean visible);
  • Description
    Specifies whether to show the upper-right menu.
  • Parameters
Parameters Data type Description
visible boolean Valid values: true: Shows the upper-right menu.
false: Hides the upper-right menu.
  • Returned value
    None.

setOptionType

  • Declaration
    void setOptionType(H5Param.OptionType type);
  • Description
    Sets the display type of upper-right menu items.
  • Parameters
Parameters Data type Description
type H5Param.OptionType The display type of the menu items.
  • Returned value
    None.

setOptionType

  • Declaration
    void setOptionType(H5Param.OptionType type, int num, boolean byIndex);
  • Description
    Sets the display type of upper-right menu items.
  • Parameters
Parameters Data type Description
type H5Param.OptionType The display type of the menu items.
num int Specifies the order of the specified icon from right to left. The value starts from 0.
byIndex boolean Specifies whether to set the display type of a specified menu item.
  • Returned value
    None.

showTitleLoading

  • Declaration
    void showTitleLoading(boolean visible);
  • Description
    Specifies whether to show the loading status in the title bar. You can select an implementation method as needed.
  • Parameters
Parameters Data type Description
visible boolean Specifies whether to show the loading status in the title bar.
  • Returned value
    None.

setBtIcon

  • Declaration
    void setBtIcon(Bitmap btIcon, int index);
  • Description
    Sets the icon of a specified upper-right button.
  • Parameters
Parameters Data type Description
btIcon Bitmap The icon of the button.
index int Specifies the order of the specified icon from right to left. The value starts from 0.
  • Returned value
    None.

setH5Page

  • Declaration
    void setH5Page(H5Page h5Page);
  • Description
    Sets the HTML5 page of a container.
  • Parameters
Parameters Data type Description
h5Page H5Page The HTML5 page.
  • Returned value
    None.

setOptionMenu

  • Declaration
    void setOptionMenu(JSONObject params);
  • Description
    Sets the upper-right menu based on the parameters passed by JavaScript objects.
  • Parameters
Parameters Data type Description
params JSONObject The parameters passed by JavaScript.
  • Returned value
    None.

getDivider

  • Declaration
    View getDivider();
  • Description
    Queries the separator between the Back button and the title content. An empty value can be returned.
  • Parameters
    None.
  • Returned value
    View: the view of the separator.

getHdividerInTitle

  • Declaration
    View getHdividerInTitle();
  • Description
    Queries the separator between the title bar and the web page. The returned value cannot be empty.
  • Parameters
    None.
  • Returned value
    View: the view of the separator.

getPopAnchor

  • Declaration
    View getPopAnchor();
  • Description
    Queries the view of the anchor in the place whether the drop-down list appears.
  • Parameters
    None.
  • Returned value
    View: the view of the anchor in the place whether the drop-down list appears.

resetTitleColor

  • Declaration
    void resetTitleColor(int color);
  • Description
    Resets the background color of the title bar.
  • Parameters
Parameters Data type Description
color int The value of the color.
  • Returned value
    None.

releaseViewList

  • Declaration
    void releaseViewList();
  • Description
    Releases a referenced view. This operation is triggered when a container page is destroyed.
  • Parameters
    None.
  • Returned value
    None.

openTranslucentStatusBarSupport

  • Declaration
    void openTranslucentStatusBarSupport(int color);
  • Description
    Sets the color of a translucent title bar.
  • Parameters
Parameters Data type Description
color int The value of the color.
  • Returned value
    None.

setTitleTxtColor

  • Declaration
    void setTitleTxtColor(int color);
  • Description
    Sets the font color in the title bar.
  • Parameters
Parameters Data type Description
color int The value of the color.
  • Returned value
    None.

getOptionMenuContainer

  • Declaration
    View getOptionMenuContainer();
  • Description
    Queries the views of the upper-right menu. The ViewGroup parameter and its subclass must be returned.
  • Parameters
    None.
  • Returned value
    View: the views of the upper-right menu.

getOptionMenuContainer

  • Declaration
    View getOptionMenuContainer(int index);
  • Description
    Queries the views of the upper-right menu based on a specified position. The ViewGroup parameter and its subclass must be returned.
  • Parameters
Parameters Data type Description
index int The position of the icon from right to left. The value starts from 0.
  • Returned value
    View: the views of the upper-right menu.

setBackgroundAlphaValue

  • Declaration
    void setBackgroundAlphaValue(int alpha);
  • Description
    Sets the transparency of the background.
  • Parameters
Parameters Data type Description
alpha int The value of the transparency.
  • Returned value
    None.

setBackgroundColor

  • Declaration
    void setBackgroundColor(int color);
  • Description
    Sets the color of the background.
  • Parameters
Parameters Data type Description
color int The value of the background color.
  • Returned value
    None.

H5AppCenterPresetProvider

getCommonResourceAppList

  • Declaration
    Set<String> getCommonResourceAppList();
  • Declaration
    Queries the global resource packages.
  • Parameters
    None.
  • Returned value
    Set<String>: the set of global resource packages.

getH5PresetPkg

  • Declaration
    H5PresetPkg getH5PresetPkg();
  • Description
    Queries preset resource packages.
  • Parameters
    None.
  • Returned value
    H5PresetPkg: the preset resource packages for HTML5 pages.

getTinyCommonApp

  • Declaration
    String getTinyCommonApp();
  • Description
    Queries the appId of the common resource package of Mini Programs.
  • Parameters
    None.
  • Returned value
    The value is of the STRING type. It indicates the appId of the common resource package for Mini Programs.

H5Plugin

onPrepare

  • Declaration
    void onPrepare(H5EventFilter filter);
  • Description
    Register an HTML5 event filter in the preparation phase.
  • Parameters
Parameters Data type Description
filter H5EventFilter The HTML5 plug-in for filtering events.
  • Returned value
    None.

interceptEvent

  • Declaration
    boolean interceptEvent(final H5Event event, final H5BridgeContext context);
  • Description
    Intercepts an event.
  • Parameters
Parameters Data type Description
event H5Event The HTML5 event.
context H5BridgeContext The bridge context of the HTML5 event.
  • Returned value
    The value is of the BOOLEAN type. Valid values: true: The operation is successful. false: The operation failed.

handleEvent

  • Declaration
    boolean handleEvent(final H5Event event, final H5BridgeContext context);
  • Description
    Specifies whether to process an event.
  • Parameters
Parameters Data type Description
event H5Event The read-only event that can be processed.
context H5BridgeContext The bridge context that is used to process some JSAPI-related events.
  • Returned value
    The value is of the BOOLEAN type. Valid values: true: The plug-in has processed the event. false: The plug-in has not processed the event.

MPNebula

downloadApp

  • Declaration
    public static void downloadApp(final String appId, final MpaasNebulaDownloadCallback mpaasNebulaDownloadCallback)
  • Description
    Downloads an offline package.
  • Parameters
Parameters Data type Description
appId String The ID of the offline package.
mpaasNebulaDownloadCallback MpaasNebulaDownloadCallback The callback function that triggers download.
  • Returned value
    None.

installApp

  • Declaration
    public static void installApp(final String appId, final MpaasNebulaInstallCallback mpaasNebulaInstallCallback)
  • Description
    Installs an offline package.
  • Parameters
Parameters Data type Description
appId String The ID of the offline package.
mpaasNebulaInstallCallback MpaasNebulaInstallCallback The callback function that triggers installation.
  • Returned value
    None.

loadOfflineNebula

  • Declaration
    public static void loadOfflineNebula(String jsonFileName, MPNebulaOfflineInfo… mpNebulaOfflineInfos)
  • Description
    Loads a preset offline package.
  • Parameters
Parameters Data type Description
jsonFileName String The preset offline package in JSON. This package can be downloaded in the console.
mpNebulaOfflineInfos MPNebulaOfflineInfo Information about the preset offline package.
  • Returned value
    None.

registerH5Plugin

  • Declaration
    public static void registerH5Plugin(String className, String bundleName, String scope, String[] events)
  • Description
    Registers a custom HTML5 plug-in that is implemented based on the JSAPI.
  • Parameters
Parameters Data type Description
className String The name of the class to which the plug-in belongs. The name must consist of the full path, including the package name and the class name.
bundleName String The name of the bundle where the plug-in is located. To view the bundle name, go to Main module/build/intermediates/bundle/META-INF/BUNDLE.MF.
scope String The scope of the plug-in. In general, the value is page.
bundleName String[] The event of the registration operation.
  • Returned value
    None.

enableAppVerification

  • Declaration
    public static void enableAppVerification(final String publicKey)
  • Description
    Enables key verification of offline packages. To make sure that the public key can be set, you must enable key verification of offline packages before you open the first offline package.
  • Parameters
Parameters Data type Description
publicKey String The public key used for verification.
  • Returned value
    None.

setCustomViewProvider

  • Declaration
    public static void setCustomViewProvider(H5ViewProvider viewProvider)
  • Description
    Sets custom views of a container, such as the title bar, menu bar, web layout, and pull-to-refresh views.
  • Parameters
Parameters Data type Description
viewProvider H5ViewProvider The provider of custom views.
  • Returned value
    None.

getH5View

  • Declaration
    public static View getH5View(Activity activity, Bundle param)
  • Description
    Queries the view of the HTML5 container.
  • Parameters
Parameters Data type Description
activity Activity The page context.
param Bundle The startup parameters, which may include the app ID or URL.
  • Returned value
    View: the view of the HTML5 container.

getH5ViewAsync

  • Declaration
    public static void getH5ViewAsync(Activity activity, Bundle param, H5PageReadyListener h5PageReadyListener)
  • Description
    Asynchronously queries the view of the HTML5 container.
  • Parameters
Parameters Data type Description
activity Activity The page context.
param Bundle The startup parameters, which may include the app ID or URL.
h5PageReadyListener H5PageReadyListener The callback function that triggers asynchronous query.
  • Returned value
    None.

AbsTitleView

resetTitle

  • Declaration
    public abstract void resetTitle();
  • Description
    Resets the navigation bar.
  • Parameters
    None.
  • Returned value
    None.

H5ViewProvider

API operations related to custom views of full-screen HTML5 pages

createTitleView

  • Declaration
    H5TitleView createTitleView(Context context);
  • Description
    Creates the title of a custom title bar.
  • Parameters
Parameters Data type Description
context Context The bridge context of the HTML5 event.
  • Returned value
    H5TitleView: the title of the custom title bar.

createNavMenu

  • Declaration
    public H5NavMenuView createNavMenu()
  • Description
    Creates a custom navigation pane.
  • Parameters
    None.
  • Returned value
    H5NavMenuView: the custom navigation pane.

createPullHeaderView

  • Declaration
    H5PullHeaderView createPullHeaderView(Context context, ViewGroup viewGroup);
  • Description
    Creates the header of the custom pull-to-refresh view.
  • Parameters
Parameters Data type Description
context Context The bridge context of the HTML5 event.
viewGroup ViewGroup The ViewGroup control.
  • Returned value
    H5PullHeaderView: the header of the custom pull-to-refresh view.

createWebContentView

  • Declaration
    H5WebContentView createWebContentView(Context context);
  • Description
    Creates the layout of WebView.
  • Parameters
Parameters Data type Description
context Context The bridge context of the HTML5 event.
  • Returned value
    H5WebContentView: the layout of the custom WebView.

ITinyOptionMenuView

getView

  • Declaration

View getView();

  • Description
    Queries the view of the current UI.
  • Parameters

None.

  • Returned value
    View: the view of the current UI.

setH5Page

  • Declaration

void setH5Page(H5Page h5Page);

  • Description
    Sets the HTML5 page of a container.
  • Parameters
Parameters Data type Description
h5Page H5Page The HTML5 page.
  • Returned value
    None.

setOptionMenuOnClickListener

  • Declaration

void setOptionMenuOnClickListener(View.OnClickListener listener);

  • Description

Sets a listener on events of tapping the option menu.

  • Parameters
Parameters Data type Description
listener View.OnClickListener The event of the view that you want to listen to.
  • Returned value

None.

setCloseButtonOnClickListener

  • Declaration

void setCloseButtonOnClickListener(View.OnClickListener listener);

  • Description

Sets a listener on events of tapping the Close button.

  • Parameters
Parameters Data type Description
listener View.OnClickListener The event of the view that you want to listen to.
  • Returned value

None.

setCloseButtonOnLongClickListener

  • Declaration

void setCloseButtonOnLongClickListener(View.OnLongClickListener listener);

  • Description
    Sets a listener on events of tapping and holding the Close button.
  • Parameters
Parameters Data type Description
listener View.OnClickListener The event of the view that you want to listen to.
  • Returned value

None.

H5Utils

setProvider

  • Declaration

void setProvider(String name, Object provider);

  • Description
    Sets the provider.
  • Parameters
Parameters Data type Description
name String The name of the provider.
provider Object The object of the provider.
  • Returned value

None.

AbsTinyOptionMenuView

onTitleChange

  • Declaration

void onTitleChange(H5TitleView title);

  • Description
    Responds to changes in the title bar.
  • Parameters
Parameters Data type Description
title H5TitleView The title bar of HTML5 pages.
  • Returned value
    None.

H5ReplaceResourceProvider

API operations related to dynamic loading of custom resources

getReplaceResourcesBundleName

  • Declaration
    String getReplaceResourcesBundleName();
  • Description
    Queries the name of the bundle where the title bar resources are located.
  • Parameters
    None.
  • Returned value
    The value is of the STRING type. The returned value indicates the name of the bundle where the title bar resources are located.

H5ErrorPageView

API operations related to custom network error pages

enableShowErrorPage

  • Declaration
    boolean enableShowErrorPage(H5Page h5Page, APWebView view, String errorUrl, int statusCode, String errorMsg, String subErrorMsg, Bundle extInfo, Object extObj);
  • Description
    Specifies whether to show a custom error page.
  • Parameters
Parameters Data type Description
h5Page H5Page The page object.
view APWebView The WebView object.
errorUrl String The URL of the error.
statusCode int The error code.
errorMsg String The description of the error.
subErrorMsg String The subclass of the error description.
extInfo Bundle Extension information.
extObj Object The type of the extension.
  • Returned value
    The value is of the BOOLEAN type. Valid values: true: Shows the custom page. In this case, the errorPageCallback method is executed. false: Hides the custom page.

H5BridgeContext

API operations used by the HTML5 plug-in to return results to JSAPI requests

sendBridgeResult

  • Declaration
    boolean sendBridgeResult(JSONObject data);
  • Description
    Returns results to the JavaScript layer. The results are consumed each time an event is returned. To use the same BridgeContext to return an event multiple times, you must call the sendBridgeResultWithCallbackKept operation.
  • Parameters
Parameters Data type Description
data JSONObject The data that you want to return to the JavaScript layer.
  • Returned value
    The value is of the BOOLEAN type. Valid values: true: The operation is successful. false: The operation failed.

sendToWeb

  • Declaration
    void sendToWeb(String action, JSONObject param, H5CallBack callback);
  • Description
    Returns results to the JavaScript layer. You can add the callback parameter to the request.
  • Parameters
Parameters Data type Description
action String The action that is performed to transfer data.
param JSONObject The data that you want to transfer to the JavaScript layer.
callback H5CallBack -
  • Returned value
    None.

sendError

  • Declaration
    boolean sendError(H5Event event, Error code);
  • Description
    Sends error information.
  • Parameters
Parameters Data type Description
event H5Event The HTML5 event.
code Error The information about the error.
  • Returned value
    The value is of the BOOLEAN type. Valid values: true: The data is transferred. false: The data fails to be transferred.

sendSuccess

  • Declaration
    void sendSuccess();
  • Description
    Calls back an HTML5 page without returning values.
  • Parameters
    None.
  • Returned value
    None.

sendError

  • Declaration
    void sendError(int error, String errorMessage);
  • Description
    Customizes an error code and an error message to return.
  • Parameters
Parameters Data type Description
error int The error code you want to return.
errorMessage String The error message you want to return.
  • Returned value
    None.

Callback function

errorPageCallback

  • Declaration
    void errorPageCallback(H5Page h5Page, APWebView view, String errorUrl, int statusCode, String errorMsg, String subErrorMsg, Bundle extInfo, Object extObj)
  • Description
    Calls back an error page.
  • Parameters
Parameters Data type Description
h5Page H5Page The page object.
view APWebView The WebView object.
errorUrl String The URL of the error.
statusCode int The error code.
errorMsg String The description of the error.
subErrorMsg String The subclass of the error description.
extInfo Bundle Extension information.
extObj Object The type of the extension.
  • Returned value
    None.