本文整理汇总了Java中android.webkit.WebSettings.setGeolocationDatabasePath方法的典型用法代码示例。如果您正苦于以下问题:Java WebSettings.setGeolocationDatabasePath方法的具体用法?Java WebSettings.setGeolocationDatabasePath怎么用?Java WebSettings.setGeolocationDatabasePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.webkit.WebSettings
的用法示例。
在下文中一共展示了WebSettings.setGeolocationDatabasePath方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initWebViewSettings
import android.webkit.WebSettings; //导入方法依赖的package包/类
private void initWebViewSettings()
{
WebSettings webSettings = wv_web.getSettings();
//可以有缓存
webSettings.setAppCacheEnabled(true);
webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
//设置支持页面js可用
webSettings.setJavaScriptEnabled(true);
webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
//设置允许访问文件数据
webSettings.setAllowFileAccess(true);
//可以使用localStorage
webSettings.setDomStorageEnabled(true);
//可以有数据库
webSettings.setDatabaseEnabled(true);
//设置定位的数据库路径
String dir = this.getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath();
webSettings.setGeolocationDatabasePath(dir);
//启用地理定位
webSettings.setGeolocationEnabled(true);
}
示例2: init
import android.webkit.WebSettings; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@SuppressLint("NewApi")
private void init(Context context) {
this.setVerticalScrollBarEnabled(false);
this.setHorizontalScrollBarEnabled(false);
if (Build.VERSION.SDK_INT < 19) {
removeJavascriptInterface("searchBoxJavaBridge_");
}
WebSettings localWebSettings = this.getSettings();
try {
// 禁用file协议,http://www.tuicool.com/articles/Q36ZfuF, 防止Android WebView File域攻击
localWebSettings.setAllowFileAccess(false);
localWebSettings.setSupportZoom(false);
localWebSettings.setBuiltInZoomControls(false);
localWebSettings.setUseWideViewPort(true);
localWebSettings.setDomStorageEnabled(true);
localWebSettings.setLoadWithOverviewMode(true);
localWebSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
localWebSettings.setPluginState(PluginState.ON);
// 启用数据库
localWebSettings.setDatabaseEnabled(true);
// 设置定位的数据库路径
String dir = context.getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath();
localWebSettings.setGeolocationDatabasePath(dir);
localWebSettings.setGeolocationEnabled(true);
localWebSettings.setJavaScriptEnabled(true);
localWebSettings.setSavePassword(false);
String agent = localWebSettings.getUserAgentString();
localWebSettings.setUserAgentString(agent);
// setCookie(context, ".baidu.com", bdussCookie);
} catch (Exception e1) {
e1.printStackTrace();
}
this.setWebViewClient(new BridgeWebViewClient());
}
示例3: initData
import android.webkit.WebSettings; //导入方法依赖的package包/类
private void initData() {
WebSettings settings = logisticsWebView.getSettings();
settings.setJavaScriptEnabled(true);//开启webview支持JS
settings.setDatabaseEnabled(true);
String dir = this.getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath();
//启用地理定位
settings.setGeolocationEnabled(true);
//设置定位的数据库路径
settings.setGeolocationDatabasePath(dir);
settings.setDomStorageEnabled(true);
settings.setCacheMode(LOAD_NO_CACHE);
}
示例4: initializeSettings
import android.webkit.WebSettings; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@SuppressLint({ "SetJavaScriptEnabled", "NewApi" })
public void initializeSettings(WebSettings settings, Context context) {
//setPageCacheCapacity2(settings);
if (API < 18) {
settings.setAppCacheMaxSize(Long.MAX_VALUE);
}
if (API < 17) {
settings.setEnableSmoothTransition(true);
}
if (API > 16) {
settings.setMediaPlaybackRequiresUserGesture(true);
}
if (API >= Build.VERSION_CODES.LOLLIPOP && !mBrowserController.isIncognito()) {
settings.setMixedContentMode(WebSettings.MIXED_CONTENT_COMPATIBILITY_MODE);
} else if (API >= Build.VERSION_CODES.LOLLIPOP) {
// We're in Incognito mode, reject
settings.setMixedContentMode(WebSettings.MIXED_CONTENT_NEVER_ALLOW);
}
settings.setDomStorageEnabled(true);
settings.setAppCacheEnabled(true);
settings.setCacheMode(WebSettings.LOAD_DEFAULT);
settings.setDatabaseEnabled(true);
settings.setSupportZoom(true);
settings.setBuiltInZoomControls(true);
settings.setDisplayZoomControls(false);
settings.setAllowContentAccess(true);
settings.setAllowFileAccess(true);
settings.setDefaultTextEncodingName("utf-8");
if (API > 16) {
settings.setAllowFileAccessFromFileURLs(false);
settings.setAllowUniversalAccessFromFileURLs(false);
}
settings.setAppCachePath(context.getDir("appcache", 0).getPath());
settings.setGeolocationDatabasePath(context.getDir("geolocation", 0).getPath());
if (API < Build.VERSION_CODES.KITKAT) {
settings.setDatabasePath(context.getDir("databases", 0).getPath());
}
}
示例5: initData
import android.webkit.WebSettings; //导入方法依赖的package包/类
@SuppressLint("SetJavaScriptEnabled")
@Override
protected void initData() {
mWebView.setHorizontalScrollBarEnabled(false);//水平不显示
mWebView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
//listview,webview中滚动拖动到顶部或者底部时的阴影
mWebView.setOverScrollMode(View.OVER_SCROLL_NEVER);
//取消滚动条白边效果
mWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
WebSettings webSettings = mWebView.getSettings();
webSettings.setRenderPriority(WebSettings.RenderPriority.HIGH);//设置渲染优先级
webSettings.setLoadWithOverviewMode(true);//缩放至屏幕大小,一定要设置
webSettings.setJavaScriptEnabled(true);//支持JS
webSettings.setAllowFileAccess(true);//设置是否允许文件访问,默认是允许的
webSettings.setSaveFormData(true);//设置是否保存表单数据,默认是保存的
webSettings.setSavePassword(true);//设置是否保存密码,默认是保存的,过时了
webSettings.setJavaScriptCanOpenWindowsAutomatically(true);//支持通过JS打开新窗口
webSettings.setUseWideViewPort(true);//是否启用支持视窗meta标记
webSettings.setTextSize(WebSettings.TextSize.NORMAL);// 固定页面字体大小
webSettings.setGeolocationEnabled(true);//启用地理定位
webSettings.setDatabaseEnabled(true);// 开启database storage API功能
webSettings.setDomStorageEnabled(true);// 开启DOM storage API 功能
String databasePath = this.getApplicationContext().getDir("database", Context
.MODE_PRIVATE).getPath();
webSettings.setDatabasePath(databasePath);// 设置数据库缓存路径
webSettings.setGeolocationDatabasePath(databasePath);//设置定位的数据库路径
webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);//支持内容重新布局
webSettings.setSupportZoom(true);//支持缩放
webSettings.setBuiltInZoomControls(true);//设置支持缩放机制
webSettings.setDisplayZoomControls(false);//设置显示缩放控件
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
//设置当一个安全站点企图加载来自一个不安全站点资源时WebView的行为
//MIXED_CONTENT_ALWAYS_ALLOW
//MIXED_CONTENT_NEVER_ALLOW
//MIXED_CONTENT_COMPATIBILITY_MODE
webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
}
mWebView.setOnLongClickListener(new View.OnLongClickListener() {//禁止长按跳出复制弹窗
@Override
public boolean onLongClick(View view) {
return true;
}
});
mWebView.setDownloadListener(new WebViewDownloadListener());
mWebView.setWebViewClient(new WVC());
mWebView.setWebChromeClient(new WCC());
Intent intent = getIntent();
String url = intent.getStringExtra(C.intent.web_view_url);
mWebView.loadUrl(url);
mAddress.setText(url);
}