所以我_1075461已经使用这个资源作为开始:http://turbomanage.wordpress.com/2012/04/23/how-to-enable-geolocation-in-a-webview-android/并且我很好地复制了C#中所需的组件,但是在WebView中加载的页面只是在地理定位提示处于待处理状态时加载的灰色页面(不允许)也没有否认) .
我有所需的权限:
这是我的webView用法
webvw = FindViewById(Resource.Id.webView1);
webvw.SetWebViewClient(new GeoWebViewClient());
webvw.SetWebChromeClient(new GeoWebChromeClient());
webvw.Settings.JavaScriptCanOpenWindowsAutomatically = true;
webvw.Settings.DisplayZoomControls = true;
webvw.Settings.JavaScriptEnabled = true;
webvw.Settings.SetGeolocationEnabled(true);
webvw.LoadUrl("https://google-developers.appspot.com/maps/documentation/javascript/examples/full/map-geolocation");
自定义类
public class GeoWebChromeClient : WebChromeClient
{
public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.ICallback callback)
{
// Always grant permission since the app itself requires location
// permission and the user has therefore already granted it
callback.Invoke(origin, false, false);
}
}
public class GeoWebViewClient : WebViewClient
{
public bool shouldOverrideUrlLoading(WebView view, string url)
{
// When user clicks a hyperlink, load in the existing WebView
view.LoadUrl(url);
return true;
}
}
有没有人有什么建议?
谢谢