Android app ERR_UNKNOWN_URL_SCHEME

ERR_UNKNOWN_URL_SCHEME appears when using WebView's loadUrl()

The online method is to remove loadUrl() in shouldOverriderUrlLoading;

ERR_UNKNOWN_URL_SCHEME also appears when loading the JS method in the local html file as follows. At this time, it can be solved by changing loadUrl() to evaluateJavascript(). ( The evaluateJavascript method requires api>19 )

        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                // A separate thread must be opened to call the JS method (otherwise it cannot be called)
                mWebView.post(new Runnable() {
                    @Override
                    public void run() {
//                        mWebView.loadUrl("index:callJS()");
//                        mWebView.loadUrl("file:///android_asset/index.html");
                        mWebView.evaluateJavascript("index:callJS()", new ValueCallback<String>() {
                            @Override
                            public void onReceiveValue(String value) {
                                Toast.makeText(MainActivity.this, value, Toast.LENGTH_SHORT).show();
                                //here is the result returned by js
                            }
                        });
            }
        });
        }
    });



Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325869850&siteId=291194637