【发布时间】:2011-09-10 14:50:50
【问题描述】:
当在浏览器中点击一个地址时,它将打开该地址的地图视图。
如何设置 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;
}
}
【问题讨论】:
-
我遇到了同样的问题,这对我来说非常适合...stackoverflow.com/questions/3583264/…
标签: android webview android-webview