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