“Load Failed” issue when opening a URL in the HTML5 container

更新时间:
复制 MD 格式

Resolve the "Load Failed" error that occurs when the HTML5 container opens a URL with an unrecognized scheme.

Problem description

The app opens an online link, redirects, and then displays a "Load Failed" message.

Troubleshooting

This error occurs when the device does not have an app that can handle the third-party scheme, causing the client to report ERR_UNKNOWN_URL_SCHEME. To troubleshoot, perform the following steps:

  1. In the Android Studio console, filter the log messages for the keyword onReceived. Check the log to see if it contains the ERR_UNKNOWN_URL_SCHEME message.

  2. If the log does not contain ERR_UNKNOWN_URL_SCHEME, join DingTalk group 145930007362 for assistance. If the log contains ERR_UNKNOWN_URL_SCHEME, resolve the issue by following the procedure below to implement the public interface H5SchemeInterceptProvider and handle Scheme requests from the web page in the handlerOnScheme method.

    1. In the H5SchemeInterceptProvider implementation class, create the handlerOnScheme method to handle schemes from the web page.

      public class H5SchemeInterceptProviderImpl implements H5SchemeInterceptProvider {
      @Override
      // Handle the scheme redirection in the following method.
      public boolean handlerOnScheme(String s, H5Page h5Page) {
      // Return true to intercept the scheme. Return false to not intercept.
       return true;
      }
      }
    2. Set the provider after mPaaS is initialized.

      MP.init(this,
              MPInitParam.obtain().setCallback(new MPInitParam.MPCallback() {
                  @Override
                  public void onInit() {
                     // This callback indicates that mPaaS has been initialized, and mPaaS related calls can be made in this callback.        
                      H5Utils.setProvider(H5SchemeInterceptProvider.class.getName(), new H5SchemeInterceptProviderImpl());     
                  }
              })
      );

      For more information, see Initialize mPaaS.

If the issue persists, prepare a demo project that reproduces the issue and join DingTalk group 145930007362 for assistance.