當前位置: 首頁>>代碼示例>>Java>>正文


Java WebSettings.setGeolocationEnabled方法代碼示例

本文整理匯總了Java中android.webkit.WebSettings.setGeolocationEnabled方法的典型用法代碼示例。如果您正苦於以下問題:Java WebSettings.setGeolocationEnabled方法的具體用法?Java WebSettings.setGeolocationEnabled怎麽用?Java WebSettings.setGeolocationEnabled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.webkit.WebSettings的用法示例。


在下文中一共展示了WebSettings.setGeolocationEnabled方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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);
}
 
開發者ID:stytooldex,項目名稱:stynico,代碼行數:22,代碼來源:lua_web.java

示例2: initWebView

import android.webkit.WebSettings; //導入方法依賴的package包/類
private void initWebView(String url) {
    WebSettings webSettings = mWebView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
    webSettings.setUseWideViewPort(true);
    webSettings.setLoadWithOverviewMode(true);
    webSettings.setBuiltInZoomControls(true);
    webSettings.setGeolocationEnabled(true);
    webSettings.setDomStorageEnabled(true);
    webSettings.setDatabaseEnabled(true);
    webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
    webSettings.setAllowFileAccess(true);
    webSettings.setAppCacheEnabled(true);
    webSettings.setDisplayZoomControls(false);
    if (Build.VERSION.SDK_INT >= 21) {
        webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
    }
    mWebView.setWebChromeClient(new MyWebChromeClient());

    mWebView.loadUrl(url);
}
 
開發者ID:woxingxiao,項目名稱:GracefulMovies,代碼行數:22,代碼來源:WebActivity.java

示例3: init

import android.webkit.WebSettings; //導入方法依賴的package包/類
private void init() {
	final WebSettings setting = getSettings();
	setting.setJavaScriptEnabled(true);
	setting.setSupportZoom(false);
	setting.setSupportMultipleWindows(true);
	setting.setSupportZoom(false);
	setting.setBuiltInZoomControls(false);
	setting.setSupportMultipleWindows(true);
	setting.setJavaScriptCanOpenWindowsAutomatically(true);
	setting.setDomStorageEnabled(true);
	setting.setNeedInitialFocus(false);
	setting.setGeolocationEnabled(true);
	setting.setAllowFileAccess(true);
	setFocusable(true);
	setFocusableInTouchMode(true);

}
 
開發者ID:fengshihao,項目名稱:WebPager,代碼行數:18,代碼來源:PagerWebView.java

示例4: JavaScriptWebView

import android.webkit.WebSettings; //導入方法依賴的package包/類
@SuppressLint("SetJavaScriptEnabled")
public JavaScriptWebView(Context context)
{
	super(context);

	mContext = context;

	WebSettings settings = getSettings();
	settings.setJavaScriptEnabled(true);
	settings.setDomStorageEnabled(true);
	settings.setGeolocationEnabled(true);
	setVerticalScrollbarOverlay(true);

	setWebChromeClient(new MyChromeClient());

	try {
	    new JavaScriptWebViewNewSettings().applySettings(this); }
	catch (java.lang.Throwable e) {}
}
 
開發者ID:sdrausty,項目名稱:buildAPKsApps,代碼行數:20,代碼來源:JavaScriptWebView.java

示例5: 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());
}
 
開發者ID:dueros,項目名稱:dcs-sdk-java,代碼行數:39,代碼來源:BaseWebView.java

示例6: setupWebView

import android.webkit.WebSettings; //導入方法依賴的package包/類
@SuppressLint("SetJavaScriptEnabled")
private void setupWebView() {

  progressBar.spin();

  final WebSettings webSettings = mWebView.getSettings();
  webSettings.setJavaScriptEnabled(true);
  webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
  webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
  webSettings.setDomStorageEnabled(true);
  webSettings.setGeolocationEnabled(true);
  webSettings.setUseWideViewPort(true);
  webSettings.setLoadWithOverviewMode(true);
  mWebView.getSettings().setBlockNetworkImage(true);
  mWebView.setWebViewClient(webViewClient);
  mWebView.requestFocus(View.FOCUS_DOWN);
  mWebView.getSettings().setDefaultTextEncodingName("UTF-8");
  mWebView.setWebChromeClient(new WebChromeClient() {

    @Override
    public boolean onJsAlert(WebView view, String url, String message, final JsResult result) {

      AlertDialog.Builder b2 = new AlertDialog
          .Builder(BrowserActivity.this)
          .setTitle(R.string.app_name)
          .setMessage(message)
          .setPositiveButton("確定", (dialog, which) -> result.confirm());

      b2.setCancelable(false);
      b2.create();
      b2.show();
      return true;
    }
  });
  mWebView.loadUrl(url);
}
 
開發者ID:MUFCRyan,項目名稱:BilibiliClient,代碼行數:37,代碼來源:BrowserActivity.java

示例7: 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);
}
 
開發者ID:MedicationReminder,項目名稱:MedicationReminder,代碼行數:15,代碼來源:LogisticsWebActivity.java

示例8: 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();
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:33,代碼來源:CustomWebView.java

示例9: b

import android.webkit.WebSettings; //導入方法依賴的package包/類
private boolean b() {
    this.b = (WebView) this.d.findViewById(ResContainer.getResourceId(this.k, ResType.ID,
            "webView"));
    this.b.setWebViewClient(c());
    this.b.setWebChromeClient(new p(this));
    this.b.requestFocusFromTouch();
    this.b.setVerticalScrollBarEnabled(false);
    this.b.setHorizontalScrollBarEnabled(false);
    this.b.setScrollBarStyle(0);
    this.b.getSettings().setCacheMode(2);
    WebSettings settings = this.b.getSettings();
    settings.setJavaScriptEnabled(true);
    if (VERSION.SDK_INT >= 8) {
        settings.setPluginState(PluginState.ON);
    }
    settings.setSupportZoom(true);
    settings.setBuiltInZoomControls(true);
    settings.setAllowFileAccess(true);
    settings.setLayoutAlgorithm(LayoutAlgorithm.NORMAL);
    settings.setUseWideViewPort(true);
    if (VERSION.SDK_INT >= 8) {
        settings.setLoadWithOverviewMode(true);
        settings.setDatabaseEnabled(true);
        settings.setDomStorageEnabled(true);
        settings.setGeolocationEnabled(true);
        settings.setAppCacheEnabled(true);
    }
    if (VERSION.SDK_INT >= 11) {
        try {
            Method declaredMethod = WebSettings.class.getDeclaredMethod
                    ("setDisplayZoomControls", new Class[]{Boolean.TYPE});
            declaredMethod.setAccessible(true);
            declaredMethod.invoke(settings, new Object[]{Boolean.valueOf(false)});
        } catch (Exception e) {
        }
    }
    try {
        if (this.m == SHARE_MEDIA.RENREN) {
            CookieSyncManager.createInstance(this.k);
            CookieManager.getInstance().removeAllCookie();
        }
    } catch (Exception e2) {
    }
    return true;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:46,代碼來源:j.java

示例10: 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);

}
 
開發者ID:fendoudebb,項目名稱:PlayAndroid,代碼行數:63,代碼來源:WebViewActivity.java


注:本文中的android.webkit.WebSettings.setGeolocationEnabled方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。