All Products
Search
Document Center

Mobile Platform as a Service:10.1.60

Last Updated:Feb 02, 2023

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

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.

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.