Create an Android WebView demo to access the web page
As a result, the simulator reported an error: webpage err_ unknown_ url_ scheme
Solution:
Method 1:
webView.setWebChromeClient(new WebChromeClient());
webView.getSettings().setJavaScriptEnabled(true); //Set the WebView properties, run the js script
webView.loadUrl("https://www.baidu.com/"); //call the loadUrl method to add a link to the WebView
setContentView(webView);
Method 2:
// webView.setWebViewClient(new WebViewClient() {
// // Set the new web page opened by clicking on the webView to be displayed in the current interface without jumping to a new browser
// @Override
// public boolean shouldOverrideUrlLoading(WebView view, String url) {
//
//
// if( url.startsWith("http:") || url.startsWith("https:") ) {
// return false;
// }
// Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
// startActivity(intent);
// // When the following line is kept, the original page still reports an error, but the new page is fine. So after commenting it out, there is no problem
// // view.loadUrl(url);
// return true;
//
//
//
//
//
//
//
//
// }
// });
Method 3:
webView.getSettings().setUserAgentString("Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:54.0) Gecko/20100101 Firefox/54.0");
It looks like it’s accessible
Method 4:
if (httpurl.startsWith(“scheme:”) || httpurl.startsWith(“scheme:”)) {
Intent intent = new Intent(Intent.ACTION_ VIEW, Uri.parse(httpurl));
startActivity(intent);
}
return false;
Method 5:
Direct return false
webView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return false;
}
});
Similar Posts:
- Android WebView monitors and rewrites window.history.go (- 1) method call
- Service Intent must be explicit solution: continued
- [Solved] Android Studio Warning: Default Activity not found
- java.lang.IllegalArgumentException: Service Intent must be explicit: Intent { act=com.ba.cal
- The newly created androidmanifesto app is not indexable by Google search;
- [Solved] The activity must be exported or contain an intent-filter
- Android didi 16: a possibility of unable to start service intent
- !!! FAILED BINDER TRANSACTION !!! resolvent
- [Solved] Using JDK dynamic agent to customize SPI Error: UndeclaredThrowableException
- Common attributes of unity inspector panel