当前位置: 首页>>代码示例>>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;未经允许,请勿转载。