How do I enable Geolocation on an Android WebView created from a Xamarin Forms shared project?

DaveMDaveM USMember

I have a Xamarin Forms shared project that simply creates a Xamarin WebView and sets it as the home page's content. This project is shared with platform-specific projects for Android, iOS, Windows 10, Windows 8.1, and Windows Phone 8.1.

In all projects, I have enabled all the required capabilities/permissions for geolocation. So far, I've been able to get the geolocation working properly for Windows 10 (though not for Windows (Phone) 8.1, but I know that's because of device limitations). What I am trying to do now is get it working on Android.

What I have found so far is I need to get the real WebView control within the Android project, and set come properties and call some methods, and geolocation will start working. However, I cannot figure out how to get the real WebView control. Everything I've found says to use FindViewById<WebView>(Resources.Id.webView1), but Resources.Id.webView1 doesn't exist in my project. Nor does any even remotely similar property exist.

There must be a way to get the real WebView control from within an Activity. My question is, how do I get it?

Sign In or Register to comment.