我正在尝试使用谷歌地图访问GPS,这是使用webview显示的。设备中启用了GPS并且具有以下权限:
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
这是我的webview部分代码:
storeLocator = (WebView) findViewById(R.id.storeLocator);
storeLocator.setWebViewClient(new WebViewClient());
storeLocator.getSettings().setJavaScriptEnabled(true);
storeLocator.getSettings().setGeolocationEnabled(true);
// storeLocator.getSettings().setBuiltInZoomControls(true);
storeLocator.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
locationDialog.show();
locationDialog.setProgress(0);
activity.setProgress(progress * 1000);
locationDialog.incrementProgressBy(progress);
if (progress == 100 && locationDialog.isShowing())
locationDialog.dismiss();
}
});
storeLocator.loadUrl(getResources().getString(R.string.location));
是否要添加任何侦听器以共享要激活的位置?
也添加了这些行,但没有效果:
storeLocator.setWebChromeClient(new WebChromeClient() {
public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) {
// Log.d("geolocation permission", "permission >>>"+origin);
callback.invoke(origin, true, false);
}});