我在Android WebView中为网站启用地理定位时遇到了一个问题。https:/www.lightningmaps.org. 设置为 myWebViev
是。
WebSettings webSettings = myWebView.getSettings();
webSettings.setAppCacheEnabled(true);
webSettings.setAppCachePath(getActivity().getApplicationContext().getDir("cache", Context.MODE_PRIVATE).getPath());
webSettings.setDatabaseEnabled(true);
String dir = getActivity().getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath();
webSettings.setDatabasePath(dir);
webSettings.setJavaScriptEnabled(true);
webSettings.setDomStorageEnabled(true);
webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
webSettings.setGeolocationEnabled(true);
myWebView.setWebChromeClient(new GeoWebChromeClient());
public class GeoWebChromeClient extends android.webkit.WebChromeClient {
@Override
public void onGeolocationPermissionsShowPrompt(String origin,
android.webkit.GeolocationPermissions.Callback callback) {
// Always grant permission since the app itself requires location
// permission and the user has therefore already granted it
callback.invoke(origin, true, false);
}
}
哪里出错了?
其他使用地理位置的网站如google.commaps也不能读取地理位置的形式设备。