I have created a WebView App with VS2015 / Xamarin. The WebView loads an external webiste (the pages are not included in the APP). One of the website pages contains an html link of this kind:
<a href="geo:42.374260,-71.120824">
I would like to make sure Android opens Google Maps App when a user clicks on the link. I have made use of ShouldOverrideUrlLoading in this way:
public class WebClient : WebViewClient
{
public override bool ShouldOverrideUrlLoading(WebView view, string url)
{
//Click on a georeferenced link
if (url.IndexOf("geo:")>-1)
{
var geoUri = Android.Net.Uri.Parse("geo:42.374260,-71.120824");
var mapIntent = new Intent(Intent.ActionView, geoUri);
StartActivity(mapIntent);
return true;
}
//Click on a generic link
view.LoadUrl(url);
return true;
}
}
Now, problem is, the StartActivity line returns an error: An object reference is required for the non-static field, method, or property 'ContextWrapper.StartActivity(Intent)'
Could you suggest which is the right syntax I should use to avoid this error ?