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


Java WebSettings.setPluginState方法代碼示例

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


在下文中一共展示了WebSettings.setPluginState方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: initWidgets

import android.webkit.WebSettings; //導入方法依賴的package包/類
@Override
protected void initWidgets() {
    super.initWidgets();
    mBackImg = (ImageView) findViewById(R.id.kf5_return_img);
    mBackImg.setOnClickListener(this);
    mWebView = (WebView) findViewById(R.id.kf5_post_detail_content);
    mDetailTitle = (TextView) findViewById(R.id.kf5_post_detail_title);
    mDate = (TextView) findViewById(R.id.kf5_post_detail_date);
    WebSettings webSettings = mWebView.getSettings();
    webSettings.setBuiltInZoomControls(false);
    webSettings.setDomStorageEnabled(true);
    webSettings.setDatabaseEnabled(true);
    webSettings.setAppCacheEnabled(true);
    webSettings.setLoadsImagesAutomatically(true);
    webSettings.setPluginState(WebSettings.PluginState.ON);
    webSettings.setBuiltInZoomControls(false); //顯示放大縮小 controler
    webSettings.setSupportZoom(false); //可以縮放
    webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
    mWebView.setWebViewClient(new MyWebViewClient());
}
 
開發者ID:Zyj163,項目名稱:yyox,代碼行數:21,代碼來源:HelpCenterTypeDetailsActivity.java

示例2: setWebView

import android.webkit.WebSettings; //導入方法依賴的package包/類
private void setWebView() {
        WebSettings ws = wvNewContent.getSettings();
        ws.setJavaScriptEnabled(true);  //支持js
        ws.setPluginState(WebSettings.PluginState.ON);//設置是否支持插件
        ws.setUseWideViewPort(false);  //將圖片調整到適合webview的大小
        ws.setSupportZoom(true);  //支持縮放
        ws.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN); //支持內容重新布局
        ws.supportMultipleWindows();  //多窗口
        ws.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);  //關閉webview中緩存
//        cache模式有如下幾種:
//        LOAD_DEFAULT: 如果我們應用程序沒有設置任何cachemode, 這個是默認的cache方式。 加載一張網頁會檢查是否有cache,如果有並且沒有過期則使用本地cache,否則從網絡上獲取。
//        LOAD_CACHE_ELSE_NETWORK: 使用cache資源,即使過期了也使用,如果沒有cache才從網絡上獲取。
//        LOAD_NO_CACHE: 不使用cache 全部從網絡上獲取
//        LOAD_CACHE_ONLY:  隻使用cache上的內容
        ws.setAllowFileAccess(true);  //設置可以訪問文件
        ws.setNeedInitialFocus(true); //當webview調用requestFocus時為webview設置節點
        ws.setBuiltInZoomControls(true); //設置支持縮放
        ws.setJavaScriptCanOpenWindowsAutomatically(true); //支持通過JS打開新窗口
        ws.setLoadWithOverviewMode(true); // 縮放至屏幕的大小
        ws.setLoadsImagesAutomatically(true);  //支持自動加載圖片
    }
 
開發者ID:guxiaonian,項目名稱:MeiLa_GNN,代碼行數:22,代碼來源:GlobalWebViewActivity.java

示例3: 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

示例4: onCreate

import android.webkit.WebSettings; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_view_noticia);

    //Pega a notícia passada pela ActivityPrincipal
    mNoticia = (Noticia)getIntent().getExtras().get("noticia");

    //Obtem da View
    mToolbar = (Toolbar) findViewById(R.id.tb_noticias);
    mToolbar.setTitle(mNoticia.getTitulo());
    setSupportActionBar(mToolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowHomeEnabled(true);
    mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onBackPressed();
        }
    });

    //Obtem da View
    mImageView = (ImageView) findViewById(R.id.iv_noticias);
    //Carrega a imagem com a biblioteca Picasso
    Picasso.with(this).load(Uri.parse(Utils.getUrlApiThumbnail(this).replace("$tipo", "noticias").replace("$id", String.valueOf(mNoticia.getId()))+"&thumb=false")).placeholder(R.drawable.no_avatar).into(mImageView);

    //Obtem da View
    mWebView = (WebView) findViewById(R.id.web_noticias);
    //Carrega o conteúdo
    mWebView.loadDataWithBaseURL("file:///android_asset/","<link rel=\"stylesheet\" type=\"text/css\" href=\"estilo.css\" />"+mNoticia.getConteudo(),"text/html", "UTF-8", null);
    //Permite Javascript e outros fatores
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.getSettings().setAllowContentAccess(true);
    WebSettings webSettings = mWebView.getSettings();
    webSettings.setPluginState(WebSettings.PluginState.ON);
    webSettings.setUseWideViewPort(true);
    mWebView.setWebChromeClient(new WebChromeClient() {});
}
 
開發者ID:alessandrojean,項目名稱:order-by-android,代碼行數:39,代碼來源:ViewNoticia.java

示例5: configWebView

import android.webkit.WebSettings; //導入方法依賴的package包/類
protected void configWebView() {
    mWebView = new WebView(getApplicationContext());
    mWebViewContainer.addView(mWebView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    WebSettings settings = mWebView.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setDefaultTextEncodingName("UTF-8");
    settings.setSupportZoom(false);
    settings.setPluginState(WebSettings.PluginState.ON);
    mWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
}
 
開發者ID:Zweihui,項目名稱:Aurora,代碼行數:11,代碼來源:BaseWebActivity.java

示例6: initWebView

import android.webkit.WebSettings; //導入方法依賴的package包/類
/**
 * 初始化瀏覽器設置信息
 */
private void initWebView() {
    cookie = CookieManager.getInstance();
    WebSettings webSettings = mWebView.getSettings();
    webSettings.setJavaScriptEnabled(true); // 啟用支持javascript
    webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);// 優先使用緩存
    webSettings.setAllowFileAccess(true);// 可以訪問文件
    webSettings.setBuiltInZoomControls(true);// 支持縮放
    if (android.os.Build.VERSION.SDK_INT >= 11) {
        webSettings.setPluginState(PluginState.ON);
        webSettings.setDisplayZoomControls(false);// 支持縮放
    }
    mWebView.setWebViewClient(new MyWebViewClient());
    mWebView.setWebChromeClient(new MyWebChromeClient());
}
 
開發者ID:hsj-xiaokang,項目名稱:OSchina_resources_android,代碼行數:18,代碼來源:BrowserFragment.java

示例7: 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");
}
 
開發者ID:liuguoquan727,項目名稱:android-study,代碼行數:41,代碼來源:WebViewUI.java

示例8: initSettings

import android.webkit.WebSettings; //導入方法依賴的package包/類
private void initSettings() {
    WebSettings webSettings = mDXHWebView.getSettings();

    webSettings.setJavaScriptEnabled(true);
    if (Build.VERSION.SDK_INT >= 16) {
        webSettings.setAllowFileAccessFromFileURLs(true);
    }
    webSettings.setDomStorageEnabled(true);
    webSettings.setAllowFileAccess(true);
    webSettings.setUseWideViewPort(true);
    webSettings.setLoadWithOverviewMode(true);

    if (NetworkUtils.isConnected(mContext) ){
        webSettings.setCacheMode(WebSettings.LOAD_DEFAULT);
    } else {
        webSettings.setCacheMode(
                WebSettings.LOAD_CACHE_ELSE_NETWORK);



    }
    webSettings.setDatabaseEnabled(true);
    webSettings.setAppCacheMaxSize(1024 * 1024 * 8);
    webSettings.setAppCacheEnabled(true);



    //File fDatabase = new File(mContext.getCacheDir().getAbsolutePath(),"webview_db");
    //webSettings.setDatabasePath(fDatabase.getAbsolutePath());
    File fAppCache = new File(mContext.getCacheDir().getAbsolutePath(),"webview_cache");
    webSettings.setAppCachePath(fAppCache.getAbsolutePath());

    webSettings.setBuiltInZoomControls(true);// api-3
    webSettings.setPluginState(WebSettings.PluginState.ON);
    webSettings.setRenderPriority(WebSettings.RenderPriority.HIGH);
    if (Build.VERSION.SDK_INT >= 11) {
        webSettings.setDisplayZoomControls(false);// api-11
    }

    //http://wiki.jikexueyuan.com/project/chrome-devtools/remote-debugging-on-android.html
    if (Build.VERSION.SDK_INT >= 19) {//for chrome debug
        WebView.setWebContentsDebuggingEnabled(true);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        webSettings.setMixedContentMode(
                WebSettings.MIXED_CONTENT_COMPATIBILITY_MODE);
    }
}
 
開發者ID:yale8848,項目名稱:CacheWebView,代碼行數:50,代碼來源:TestWebView.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


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