當瀏覽器中的地址叮噹響時,它將打開地址的地圖視圖。如何處理地圖:webview中的鏈接
如何設置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;
}
}
我有同樣的問題,這個工作非常適合我... http://stackoverflow.com/questions/3583264/support-for-other-protocols-in-android-webview – droopie 2011-12-24 23:56:55