0

When clinking on an address in the browser, it will open a map view for the address.

How do I set shouldOverrideUrlLoading to handle these links in a WebView? I have setup handling of "tel:" and "mailto:" links, but can't figure out how to handle "geo:" links.

My 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;
        }
    }
Joshua
  • 3
  • 1
  • 3
  • i had the same issue and this worked perfect for me... http://stackoverflow.com/questions/3583264/support-for-other-protocols-in-android-webview – droopie Dec 24 '11 at 23:56

1 Answers1

0

I was having the same problem. I pieced it together by looking at this question:

Question on geo:

the code to add to yours is below... btw, you helped me solve the tel: issue! thx!

else if (url.startsWith("geo:")) {
        Intent searchAddress = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); 
        startActivity(searchAddress); 
}
Community
  • 1
  • 1
TrippinBilly
  • 957
  • 2
  • 10
  • 19
  • Hi I tried handling geo: links in my webview as suggested here. But I get an error as : android.content.ActivityNotFoundException: No Activity found to handle Intent. How should this be solved? – Zeba Aug 30 '12 at 10:16