本文整理汇总了Java中android.webkit.WebSettings.setDatabaseEnabled方法的典型用法代码示例。如果您正苦于以下问题:Java WebSettings.setDatabaseEnabled方法的具体用法?Java WebSettings.setDatabaseEnabled怎么用?Java WebSettings.setDatabaseEnabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.webkit.WebSettings
的用法示例。
在下文中一共展示了WebSettings.setDatabaseEnabled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeEncryToken
import android.webkit.WebSettings; //导入方法依赖的package包/类
@SuppressLint({"SetJavaScriptEnabled"})
public void writeEncryToken(Context context) {
String str = "tencent&sdk&qazxc***14969%%";
String accessToken = this.mToken.getAccessToken();
String appId = this.mToken.getAppId();
String openId = this.mToken.getOpenId();
String str2 = "qzone3.4";
if (accessToken == null || accessToken.length() <= 0 || appId == null || appId.length() <= 0 || openId == null || openId.length() <= 0) {
str = null;
} else {
str = Util.encrypt(str + accessToken + appId + openId + str2);
}
com.tencent.open.c.b bVar = new com.tencent.open.c.b(context);
WebSettings settings = bVar.getSettings();
settings.setDomStorageEnabled(true);
settings.setJavaScriptEnabled(true);
settings.setDatabaseEnabled(true);
accessToken = "<!DOCTYPE HTML><html lang=\"en-US\"><head><meta charset=\"UTF-8\"><title>localStorage Test</title><script type=\"text/javascript\">document.domain = 'qq.com';localStorage[\"" + this.mToken.getOpenId() + EventsFilesManager.ROLL_OVER_FILE_NAME_SEPARATOR + this.mToken.getAppId() + "\"]=\"" + str + "\";</script></head><body></body></html>";
str = ServerSetting.getInstance().getEnvUrl(context, ServerSetting.DEFAULT_LOCAL_STORAGE_URI);
bVar.loadDataWithBaseURL(str, accessToken, "text/html", "utf-8", str);
}
示例2: 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);
}
示例3: a
import android.webkit.WebSettings; //导入方法依赖的package包/类
protected RegisterView a() {
RegisterView registerView = new RegisterView(this.activity);
registerView.c().getChildAt(registerView.c().getChildCount() - 1).setVisibility(8);
registerView.a().setOnClickListener(new j(this));
this.e = registerView.b();
WebSettings settings = this.e.getSettings();
settings.setBuiltInZoomControls(true);
settings.setJavaScriptEnabled(true);
settings.setCacheMode(1);
settings.setDomStorageEnabled(true);
settings.setDatabaseEnabled(true);
settings.setDatabasePath(this.activity.getDir("database", 0).getPath());
this.e.setVerticalScrollBarEnabled(false);
this.e.setHorizontalScrollBarEnabled(false);
this.e.setWebViewClient(new l(this));
return registerView;
}
示例4: setCachePath
import android.webkit.WebSettings; //导入方法依赖的package包/类
private void setCachePath(){
File cacheFile = new File(this.getContext().getCacheDir(),CACHE_NAME);
String path = cacheFile.getAbsolutePath();
mAppCachePath = path;
File file = new File(path);
if (!file.exists()){
file.mkdirs();
}
WebSettings webSettings = this.getSettings();
webSettings.setAppCacheEnabled(true);
webSettings.setDatabaseEnabled(true);
webSettings.setDatabasePath(path);
}
示例5: createWebView
import android.webkit.WebSettings; //导入方法依赖的package包/类
@SuppressLint("SetJavaScriptEnabled")
public WebView createWebView(WebView webView) {
//WebView.setWebContentsDebuggingEnabled(true);
//不能横向滚动
webView.setHorizontalScrollBarEnabled(false);
//不能纵向滚动
webView.setVerticalScrollBarEnabled(false);
//允许截图
webView.setDrawingCacheEnabled(true);
//屏蔽长按事件
webView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
return true;
}
});
//初始化WebSettings
final WebSettings settings = webView.getSettings();
settings.setJavaScriptEnabled(true);
final String ua = settings.getUserAgentString();
settings.setUserAgentString(ua + "Latte");
//隐藏缩放控件
settings.setBuiltInZoomControls(false);
settings.setDisplayZoomControls(false);
//禁止缩放
settings.setSupportZoom(false);
//文件权限
settings.setAllowFileAccess(true);
settings.setAllowFileAccessFromFileURLs(true);
settings.setAllowUniversalAccessFromFileURLs(true);
settings.setAllowContentAccess(true);
//缓存相关
settings.setAppCacheEnabled(true);
settings.setDomStorageEnabled(true);
settings.setDatabaseEnabled(true);
settings.setCacheMode(WebSettings.LOAD_DEFAULT);
return webView;
}
示例6: 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());
}
示例7: MarkdownView
import android.webkit.WebSettings; //导入方法依赖的package包/类
@SuppressLint({"AddJavascriptInterface", "SetJavaScriptEnabled"})
public MarkdownView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
if (isInEditMode()) {
return;
}
WebSettings settings = getSettings();
settings.setJavaScriptEnabled(true);
settings.setDomStorageEnabled(true);
settings.setDatabaseEnabled(true);
initialize();
}
示例8: 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);
}
示例9: initWebSettings
import android.webkit.WebSettings; //导入方法依赖的package包/类
private void initWebSettings() {
WebSettings settings = mWebView.getSettings();
//支持获取手势焦点
mWebView.requestFocusFromTouch();
//支持JS
settings.setJavaScriptEnabled(true);
//支持插件
settings.setPluginState(WebSettings.PluginState.ON);
//设置适应屏幕
settings.setUseWideViewPort(true);
settings.setLoadWithOverviewMode(true);
//支持缩放
settings.setSupportZoom(false);
//隐藏原生的缩放控件
settings.setDisplayZoomControls(false);
//支持内容重新布局
settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
settings.supportMultipleWindows();
settings.setSupportMultipleWindows(true);
//设置缓存模式
settings.setDomStorageEnabled(true);
settings.setDatabaseEnabled(true);
settings.setCacheMode(WebSettings.LOAD_DEFAULT);
settings.setAppCacheEnabled(true);
settings.setAppCachePath(mWebView.getContext().getCacheDir().getAbsolutePath());
//设置可访问文件
settings.setAllowFileAccess(true);
//当webview调用requestFocus时为webview设置节点
settings.setNeedInitialFocus(true);
//支持自动加载图片
if (Build.VERSION.SDK_INT >= 19) {
settings.setLoadsImagesAutomatically(true);
} else {
settings.setLoadsImagesAutomatically(false);
}
settings.setNeedInitialFocus(true);
//设置编码格式
settings.setDefaultTextEncodingName("UTF-8");
}
示例10: init
import android.webkit.WebSettings; //导入方法依赖的package包/类
private void init(Context context) {
mPlayer = new WebPlayer(this);
setBackgroundColor(Color.BLACK);
enableJavascript();
WebSettings webSettings = getSettings();
webSettings.setAllowContentAccess(true);
webSettings.setAllowFileAccess(true);
webSettings.setLoadsImagesAutomatically(true);
webSettings.setDomStorageEnabled(true);
webSettings.setAppCacheEnabled(true);
webSettings.setDatabaseEnabled(true);
webSettings.setDatabasePath(context.getDir("database", Context.MODE_PRIVATE).getPath());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
webSettings.setAllowFileAccessFromFileURLs(true);
webSettings.setAllowUniversalAccessFromFileURLs(true);
}
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
webSettings.setRenderPriority(WebSettings.RenderPriority.HIGH);
}
setWebChromeClient(new ChromeClient());
setWebViewClient(new ViewClient());
}
示例11: initializeOptions
import android.webkit.WebSettings; //导入方法依赖的package包/类
@SuppressLint({"SetJavaScriptEnabled", "NewApi"})
public void initializeOptions() {
WebSettings settings = getSettings();
if (VERSION.SDK_INT >= 21) {
CookieManager.getInstance().setAcceptThirdPartyCookies(this, true);
}
settings.setUserAgentString(OtherUtil.getUserAgent(this.mContext));
settings.setJavaScriptEnabled(true);
settings.setJavaScriptCanOpenWindowsAutomatically(true);
settings.setCacheMode(2);
settings.setAllowFileAccess(true);
settings.setDefaultTextEncodingName("utf-8");
settings.setAppCacheEnabled(true);
settings.setGeolocationEnabled(true);
settings.setDatabaseEnabled(true);
settings.setDomStorageEnabled(true);
settings.setBuiltInZoomControls(true);
settings.setDisplayZoomControls(false);
settings.setLoadsImagesAutomatically(true);
settings.setUseWideViewPort(true);
settings.setLoadWithOverviewMode(true);
settings.setSaveFormData(true);
CookieManager.getInstance().setAcceptCookie(true);
setLongClickable(false);
setScrollbarFadingEnabled(true);
setScrollBarStyle(0);
setDrawingCacheEnabled(true);
setClickable(true);
setVerticalScrollBarEnabled(false);
setHorizontalScrollBarEnabled(false);
requestFocus();
}
示例12: initWebView
import android.webkit.WebSettings; //导入方法依赖的package包/类
public void initWebView(WebView webView) {
webView.setVerticalScrollBarEnabled(false);
webView.setBackgroundColor(getResources().getColor(R.color.white));
//设置webview的配置
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE
| WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
WebSettings webseting = webView.getSettings();
// 支持JavaScript
webseting.setJavaScriptEnabled(true);
// 支持保存数据
webseting.setSaveFormData(false);
webseting.setDomStorageEnabled(true);
// webseting.setAppCacheMaxSize(1024 * 1024 * 8);// 设置缓冲大小,我设的是8M
String appCacheDir = getApplicationContext().getDir("cache", Context.MODE_PRIVATE).getPath();
webseting.setAppCachePath(appCacheDir);
webseting.setUserAgentString(Config.FORMAT_USER_AGENT);
webseting.setLoadWithOverviewMode(true);
webseting.setUseWideViewPort(true);
webseting.setDatabaseEnabled(true);
webseting.setAllowFileAccess(true);
webseting.setCacheMode(WebSettings.LOAD_DEFAULT);
/*强制webview使用标准字号大小*/
webseting.setTextZoom(100);
// webseting.setBlockNetworkImage(true);
webseting.setLoadsImagesAutomatically(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
webView.setWebContentsDebuggingEnabled(true);// Enables debugging of web contents (HTML / CSS / JavaScript) loaded into any WebViews of this application.
}
//移除webkit内部存在安全漏洞的javascript接口
webView.removeJavascriptInterface("searchBoxJavaBridge_");
webView.removeJavascriptInterface("accessibility");
webView.removeJavascriptInterface("accessibilityTraversal");
}
示例13: b
import android.webkit.WebSettings; //导入方法依赖的package包/类
@SuppressLint({"SetJavaScriptEnabled"})
private void b() {
this.i.setVerticalScrollBarEnabled(false);
this.i.setHorizontalScrollBarEnabled(false);
this.i.setWebViewClient(new FbWebViewClient());
this.i.setWebChromeClient(this.mChromeClient);
this.i.clearFormData();
WebSettings settings = this.i.getSettings();
settings.setSavePassword(false);
settings.setSaveFormData(false);
settings.setCacheMode(-1);
settings.setNeedInitialFocus(false);
settings.setBuiltInZoomControls(true);
settings.setSupportZoom(true);
settings.setRenderPriority(RenderPriority.HIGH);
settings.setJavaScriptEnabled(true);
if (!(this.c == null || this.c.get() == null)) {
settings.setDatabaseEnabled(true);
settings.setDatabasePath(((Context) this.c.get()).getApplicationContext().getDir("databases", 0).getPath());
}
settings.setDomStorageEnabled(true);
this.jsBridge.a(new JsListener(), "sdk_js_if");
this.i.loadUrl(this.e);
this.i.setLayoutParams(a);
this.i.setVisibility(4);
this.i.getSettings().setSavePassword(false);
}
示例14: b
import android.webkit.WebSettings; //导入方法依赖的package包/类
@SuppressLint({"SetJavaScriptEnabled"})
private void b() {
this.i.setVerticalScrollBarEnabled(false);
this.i.setHorizontalScrollBarEnabled(false);
this.i.setWebViewClient(new FbWebViewClient());
this.i.setWebChromeClient(this.mChromeClient);
this.i.clearFormData();
WebSettings settings = this.i.getSettings();
settings.setSavePassword(false);
settings.setSaveFormData(false);
settings.setCacheMode(-1);
settings.setNeedInitialFocus(false);
settings.setBuiltInZoomControls(true);
settings.setSupportZoom(true);
settings.setRenderPriority(RenderPriority.HIGH);
settings.setJavaScriptEnabled(true);
if (!(this.c == null || this.c.get() == null)) {
settings.setDatabaseEnabled(true);
settings.setDatabasePath(((Context) this.c.get()).getApplicationContext().getDir
("databases", 0).getPath());
}
settings.setDomStorageEnabled(true);
this.jsBridge.a(new JsListener(), "sdk_js_if");
this.i.loadUrl(this.e);
this.i.setLayoutParams(a);
this.i.setVisibility(4);
this.i.getSettings().setSavePassword(false);
}
示例15: 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);
}