当在浏览器中的地址上叮当作响时,它将打开地址的地图视图。
如何设置shouldOverrideUrlLoading以在WebView中处理这些链接?我已设置处理“tel:”和“mailto:”链接,但无法弄清楚如何处理“geo:”链接。
我的shouldOverrideUrlLoading:
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.startsWith("tel:")) {
startActivity(new Intent(Intent.ACTION_DIAL, Uri.parse(url)));
return true;
} else if (url.startsWith("mailto:")) {
url = url.replaceFirst("mailto:", "");
url = url.trim();
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("plain/text").putExtra(Intent.EXTRA_EMAIL, new String[]{url});
startActivity(i);
return true;
} else if (url.startsWith("geo:")) {
return true;
} else {
view.loadUrl(url);
return true;
}
}
答案 0 :(得分:0)
我遇到了同样的问题。我通过查看这个问题将它拼凑在一起:
添加到你的代码是...... btw,你帮我解决了tel:问题! THX!
else if (url.startsWith("geo:")) {
Intent searchAddress = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(searchAddress);
}