All Products
Document Center

FAQ of using HTML5 in Android

Last Updated: Jun 01, 2021

When customizing JSAPI, what are the differences between interceptEvent and handleEvent?

A: If you want to monitor other events of the container, write your code in interceptEvent. If you want to handle the event only by yourself, write your code in handleEvent and remember to return true.

If you return true, the event will stop propagating. If your return false, the event will continue to propagate to other plug-ins.

When customizing JSAPI, I have added the events in config.setEvents("event"). Why is it that I also have to add the events in onPrepare of the plug-in?

A: Because the plug-in of the container is lazily loaded, that is, it is loaded upon page creation. The HTML5 container injects the events to be monitored through external config.setEvents. So, the corresponding plug-in object will be instantiated only when there are actual JavaScript calls. For the actual instantiated plug-in, the events distributed are those in onPrepare in the plug-in. So, you must ensure the events added in config.setEvents("event") are consistent with those in the internal onPrepare.

What are the differences between page, session, and service registered by the customized JSAPI plug-in?

A: A page corresponds to a webview. A session corresponds to an app object in mPaaS. A service is a global singleton.

  • If the plug-in is registered at page level, a plug-in instance is created every time you create a WebView, and the onRelease of the corresponding plug-in is called back when the WebView is disposed.
  • If the plug-in is registered at session level, a plug-in is created every time you create an app object.
  • If the plug-in is registered at service level, only one plug-in is created globally, and it is created when your open the container for the first time.

The purpose of signature verification is to verify source of the offline package? Or will it perform integrity verification?

A: On the offline package release platform, if you have configured a private key for the signature, the .amr files released by the platform will include the offline packages’ signature information, which is the ciphertext obtained by encrypting the offline packages’ hash values using the private key. Signature verification is performed using the public key preset in the project. First, decrypt the ciphertext mentioned above to obtain the hash value. Second, compute the hash value of the offline package locally. Third, check if the two hash values are the same.
This process ensure not only integrity of the offline package but also correct source of the offline package.

When opening an offline package, why is that I cannot hide the ProgressBar?

A: You may encounter this problem when resources fail to go offline and the page falls back to online mode. In fallback mode, the HTML5 container mandate the ProgressBar and you cannot hide it by setting the SHOW_PROGRESS startup parameter.