当前位置: 首页>>代码示例>>Java>>正文


Java WebSettings类代码示例

本文整理汇总了Java中android.webkit.WebSettings的典型用法代码示例。如果您正苦于以下问题:Java WebSettings类的具体用法?Java WebSettings怎么用?Java WebSettings使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


WebSettings类属于android.webkit包,在下文中一共展示了WebSettings类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: clearWebViewAllCache

import android.webkit.WebSettings; //导入依赖的package包/类
static void clearWebViewAllCache(Context context, WebView webView) {

        try {

            AgentWebConfig.removeAllCookies(null);
            webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
            context.deleteDatabase("webviewCache.db");
            context.deleteDatabase("webview.db");
            webView.clearCache(true);
            webView.clearHistory();
            webView.clearFormData();
            clearCacheFolder(new File(AgentWebConfig.getCachePath(context)), 0);

        } catch (Exception ignore) {
            //ignore.printStackTrace();
            if (AgentWebConfig.DEBUG)
                ignore.printStackTrace();
        }
    }
 
开发者ID:Justson,项目名称:AgentWeb,代码行数:20,代码来源:AgentWebUtils.java

示例2: openCache

import android.webkit.WebSettings; //导入依赖的package包/类
public void openCache(String cacheDirPath){
    //设置缓存模式
    mWebSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
    // 开启DOM storage API 功能
    mWebSettings.setDomStorageEnabled(true);
    // 开启database storage API功能
    mWebSettings.setDatabaseEnabled(true);
    // 设置数据库缓存路径
    mWebSettings.setAppCachePath(cacheDirPath);
    mWebSettings.setAppCacheEnabled(true);
}
 
开发者ID:bigjelly,项目名称:ShaddockVideoPlayer,代码行数:12,代码来源:NWebView.java

示例3: initWebView

import android.webkit.WebSettings; //导入依赖的package包/类
private void initWebView() {
    WebSettings webSettings = mWebView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    /*使webview能够加载图片*/
    webSettings.setBlockNetworkImage(false);
    webSettings.setAppCacheEnabled(true);
    mDialog=new SpotsDialog(this);
    mDialog.show();
    mWebView.loadUrl(mMessage.getClickUrl());
    //        mWebAppInterface = new WebAppInterface(this);
    //        mWebView.addJavascriptInterface(mWebAppInterface, "appInterface");
    mWebView.setWebViewClient(new MyWebChromeC());
    mWebView.setWebChromeClient(new WebChromeClient(){

    });

}
 
开发者ID:yiwent,项目名称:Mobike,代码行数:18,代码来源:TripDetailActivity.java

示例4: init

import android.webkit.WebSettings; //导入依赖的package包/类
@SuppressLint("SetJavaScriptEnabled")
private void init(Context context) {
    // 顶部显示的进度条
    mProgressBar = new ProgressBar(context, null, android.R.attr.progressBarStyleHorizontal);
    mProgressBar.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, 7, 0, 0));
    Drawable drawable = context.getResources().getDrawable(R.drawable.layer_web_progress_bar);
    mProgressBar.setProgressDrawable(drawable);
    addView(mProgressBar);

    WebSettings webSettings = this.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setSupportZoom(true);   // 是能放大缩小
    webSettings.setUseWideViewPort(true);
    webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
    webSettings.setLoadWithOverviewMode(true);
    webSettings.setBuiltInZoomControls(true);
    webSettings.setDisplayZoomControls(false);//隐藏
    webSettings.setDomStorageEnabled(true);
    webSettings.setSupportMultipleWindows(true);
    //webSettings.setUseWideViewPort(true);
    this.setWebViewClient(mWebViewClientBase);
    this.setWebChromeClient(mWebChromeClientBase);
    setDownloadListener(new DownloadListener());
    this.onResume();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:26,代码来源:CustomWebView.java

示例5: setWebView

import android.webkit.WebSettings; //导入依赖的package包/类
private void setWebView(String product_id) {

        if (product_id != null) {
            //http://192.168.51.104:8080/atguigu/json/GOODSINFO_URL.json2691
//            wbGoodInfoMore.loadUrl(Constants.GOODSINFO_URL + product_id);
            wbGoodInfoMore.loadUrl("http://www.atguigu.com");
            //覆盖WebView默认使用第三方或系统默认浏览器打开网页的行为,使网页用WebView打开
            wbGoodInfoMore.setWebViewClient(new WebViewClient() {
                @Override
                public boolean shouldOverrideUrlLoading(WebView view, String url) {
                    //返回值是true的时候控制去WebView打开,为false调用系统浏览器或第三方浏览器
                    view.loadUrl(url);
                    return true;
                }
            });
            //启用支持javascript
            WebSettings settings = wbGoodInfoMore.getSettings();
            settings.setJavaScriptEnabled(true);
            settings.setUseWideViewPort(true);

            //优先使用缓存
            wbGoodInfoMore.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
        }
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:GoodsInfoActivity.java

示例6: onCreate

import android.webkit.WebSettings; //导入依赖的package包/类
@Override
@SuppressLint("SetJavaScriptEnabled")
protected void onCreate(Bundle savedInstanceState)
{
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_privacy_policy);

  final WebView privacyPolicyWebView = (WebView)findViewById(R.id.privacypolicy);
  privacyPolicyWebView.setVisibility(View.VISIBLE);
  privacyPolicyWebView.getSettings().setJavaScriptEnabled(true);
  privacyPolicyWebView.getSettings().setRenderPriority(RenderPriority.HIGH);
  privacyPolicyWebView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
  privacyPolicyWebView.setWebViewClient(new WebViewClient() { });
  privacyPolicyWebView.resumeTimers();
  privacyPolicyWebView.loadUrl("http://www.soasta.com/privacy-policy");
}
 
开发者ID:SOASTA,项目名称:touchtestweb-android,代码行数:17,代码来源:PrivacyPolicyActivity.java

示例7: preSetting

import android.webkit.WebSettings; //导入依赖的package包/类
private void preSetting(){
    //加载服务器上的页面
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.getSettings().setBlockNetworkImage(false);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        mWebView.getSettings().setMixedContentMode(
                WebSettings.MIXED_CONTENT_COMPATIBILITY_MODE);
    }
    mWebView.setWebViewClient(new WebViewClient() {
        @Override
        public void onReceivedSslError(WebView view,
                                       SslErrorHandler handler, SslError error) {
            // TODO Auto-generated method stub
            // handler.cancel();// Android默认的处理方式
            handler.proceed();// 接受所有网站的证书
            // handleMessage(Message msg);// 进行其他处理
        }
    });
    //加载本地中的html
    //myWebView.loadUrl("file:///android_asset/www/test2.html");
    //加上下面这段代码可以使网页中的链接不以浏览器的方式打开
    mWebView.setWebViewClient(new WebViewClient());
    //允许使用javascript
    mWebView.getSettings().setJavaScriptEnabled(true);
}
 
开发者ID:MarukoZ,项目名称:FaceRecognition,代码行数:26,代码来源:Main2Activity.java

示例8: initWebViewSettings

import android.webkit.WebSettings; //导入依赖的package包/类
/**
 * @param webView
 */
@SuppressLint("SetJavaScriptEnabled")
public static void initWebViewSettings(WebView webView) {
    WebSettings webSettings = webView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setUseWideViewPort(true);
    webSettings.setLoadWithOverviewMode(true);
    webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
    webSettings.setDefaultFontSize(15);
    //设置缓存
    webSettings.setDomStorageEnabled(true);
    webSettings.setDatabaseEnabled(true);

    webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
    webSettings.setAppCacheEnabled(true);
    webSettings.setAllowFileAccess(true);
    webSettings.setAppCachePath(AppConfig.WEB_CACHE_PATH);
}
 
开发者ID:z-chu,项目名称:FriendBook,代码行数:21,代码来源:AppRouter.java

示例9: loadData

import android.webkit.WebSettings; //导入依赖的package包/类
private void loadData() {
    Picasso.with(this).load(getIntent("thumbnail")).into(imgCover);
    txtWriter.setText(getIntent("writer"));
    txtDate.setText(getIntent("date"));
    webViewContent.setScrollContainer(false);
    webViewContent.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
    webViewContent.loadData(WebViewContent.clean(getContent()), "text/html; charset=utf-8", "utf-8");
}
 
开发者ID:daeng-id,项目名称:nfkita-mobile,代码行数:9,代码来源:ReadArticleActivity.java

示例10: onCreate

import android.webkit.WebSettings; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_about);

    getSupportActionBar().setTitle(getString(R.string.about));
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    progressBar = (ProgressBar) findViewById(R.id.progress);
    progressBar.getIndeterminateDrawable()
            .setColorFilter(ContextCompat.getColor(this, R.color.colorPrimary), PorterDuff.Mode.SRC_IN);
    info_web = (WebView) findViewById(R.id.webview_company_info);
    info_web.setBackgroundColor(Color.TRANSPARENT);
    info_web.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    info_web.setWebViewClient(new myWebClient());
    info_web.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
    info_web.getSettings().setJavaScriptEnabled(true);
    String infoText = getString(R.string.company_info_web);
    info_web.loadDataWithBaseURL("file:///android_asset/fonts/", getWebViewText(infoText), "text/html", "utf-8", null);

}
 
开发者ID:fekracomputers,项目名称:QuranAndroid,代码行数:22,代码来源:AboutActivity.java

示例11: onCreate

import android.webkit.WebSettings; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    webView = (WebView) findViewById(R.id.webView);

    WebSettings settings = webView.getSettings();
    settings.setAllowFileAccessFromFileURLs(true);
    settings.setJavaScriptEnabled(true);

    webView.addJavascriptInterface(new JavascriptHandler(this, webView), "JavascriptHandler");

    webView.loadUrl("file:///android_asset/Sample.framer/index.html");
}
 
开发者ID:mirhoseini,项目名称:framer-android-wrapper,代码行数:16,代码来源:MainActivity.java

示例12: loadImage

import android.webkit.WebSettings; //导入依赖的package包/类
public void loadImage(@NonNull String url, boolean isSvg) {
    WebSettings settings = getSettings();
    settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
    setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
    settings.setSupportZoom(true);
    settings.setBuiltInZoomControls(true);
    settings.setDisplayZoomControls(false);
    String html;
    if (isSvg) {
        html = url;
    } else {
        html = "<html><head><style>img{display: inline; height: auto; max-width: 100%;}</style></head><body>" +
                "<img src=\"" + url + "\"/></body></html>";
    }
    Logger.e(html);
    loadData(html, "text/html", null);
}
 
开发者ID:duyp,项目名称:mvvm-template,代码行数:18,代码来源:PrettifyWebView.java

示例13: initView

import android.webkit.WebSettings; //导入依赖的package包/类
@Override
public void initView() {
    mIbToolbarMore.setVisibility(View.VISIBLE);
    //设置webView
    WebSettings settings = mWebView.getSettings();
    settings.setRenderPriority(WebSettings.RenderPriority.HIGH);
    settings.setSupportMultipleWindows(true);
    settings.setJavaScriptEnabled(true);
    settings.setSavePassword(false);
    settings.setJavaScriptCanOpenWindowsAutomatically(true);
    settings.setMinimumFontSize(settings.getMinimumLogicalFontSize() + 8);
    settings.setAllowFileAccess(false);
    settings.setTextSize(WebSettings.TextSize.NORMAL);
    mWebView.setVerticalScrollbarOverlay(true);
    mWebView.setWebViewClient(new MyWebViewClient());
    mWebView.loadUrl(mUrl);
    setToolbarTitle(TextUtils.isEmpty(mTitle) ? mWebView.getTitle() : mTitle);
}
 
开发者ID:GitLqr,项目名称:LQRWeChat,代码行数:19,代码来源:WebViewActivity.java

示例14: initViews

import android.webkit.WebSettings; //导入依赖的package包/类
@SuppressLint("SetJavaScriptEnabled")
@Override
protected void initViews() {
    setTitle(getIntent().getStringExtra(EXTRA_TITLE));

    WebSettings settings = mWebView.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setLoadWithOverviewMode(true);
    settings.setAppCacheEnabled(true);
    settings.setSupportZoom(true);
    settings.setUseWideViewPort(true);
    settings.setLoadWithOverviewMode(true);
    settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);

    mUrl = getIntent().getStringExtra(EXTRA_URL);
    mWebView.loadUrl(mUrl);
    mWebView.setWebChromeClient(new WebChromeClient());
    mWebView.setWebViewClient(new WebViewClient() {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            return false;
        }
    });
}
 
开发者ID:Shuanghua,项目名称:LikeGank,代码行数:25,代码来源:WebViewActivity.java

示例15: 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;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:18,代码来源:i.java


注:本文中的android.webkit.WebSettings类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。