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:
-
In the Android Studio console, filter the log messages for the keyword
onReceived. Check the log to see if it contains theERR_UNKNOWN_URL_SCHEMEmessage. -
If the log does not contain
ERR_UNKNOWN_URL_SCHEME, join DingTalk group 145930007362 for assistance. If the log containsERR_UNKNOWN_URL_SCHEME, resolve the issue by following the procedure below to implement thepublic interface H5SchemeInterceptProviderand handleSchemerequests from the web page in thehandlerOnSchememethod.-
In the
H5SchemeInterceptProviderimplementation class, create thehandlerOnSchememethod 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; } } -
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.