HTML5 container intercepts physical keys

更新时间:
复制 MD 格式

To intercept physical key presses in an HTML5 container, upgrade the mPaaS baseline to 10.1.68.33 or later. Set the provider for intercepting the physical back button as shown below.

public interface MPH5OnKeyDownProvider {
    boolean needIntercept(H5Page page, int keyCode, KeyEvent intent);
    boolean onKeyDown(H5Page page, int keyCode, KeyEvent intent);
}

If needIntercept returns true, the onKeyDown method runs to handle the key press logic, and the default mPaaS back button behavior is skipped. If needIntercept returns false, the event falls through to the default mPaaS logic and onKeyDown does not run.

Important

When implementing the needIntercept and onKeyDown methods, check their parameters for null values.