本文整理匯總了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);
}