我的代码是:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_web_view);
ButterKnife.bind(this);
String url = getIntent().getStringExtra(EXTRA_URL);
webView.setWebChromeClient(new WebChromeClient());
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl(url);
webView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(intent);
return true;
}
});
}
按下发送邮件链接时,显示以下错误:
净:: ERR_UNKNOWN_URL_SCHEME
问候!!
答案 0 :(得分:0)
在设置webviewclient之前加载网址。尝试先设置webviewclient,然后再调用loadUrl()。
修改强>
@Override
public boolean shouldOverrideUrlLoading (WebView view, String url) {
Uri uri = Uri.parseUri(url);
if ("mailto".equalsIgnoreCase(uri.getScheme()) == true) {
try {
// handle mailto-urls...
Intent sendIntent = new Intent(Intent.ACTION_SENDTO);
sendIntent.setData(uri);
view.getContext().startActivity(sendIntent);
} catch (ActivityNotFoundException e) {}
return true;
}
// load everything else in webview
return false;
}