1 //启用数据库
2 webSettings.setDatabaseEnabled(true);
3 String dir = this.getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath();
5 //启用地理定位
6 webSettings.setGeolocationEnabled(true);
7 //设置定位的数据库路径
8 webSettings.setGeolocationDatabasePath(dir);
10 //最重要的方法,一定要设置,这就是出不来的主要原因
12 webSettings.setDomStorageEnabled(true);
13 //配置权限(同样在WebChromeClient中实现)
1 public void onGeolocationPermissionsShowPrompt(String origin,
2 GeolocationPermissions.Callback callback) {
3 callback.invoke(origin, true, false);
4 super.onGeolocationPermissionsShowPrompt(origin, callback);
5 }
配置权限:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />