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


Java WebSettings.setDefaultTextEncodingName方法代碼示例

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


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

示例1: initWebView

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

        webSettings.setUseWideViewPort(true); //將圖片調整到適合webview的大小
        webSettings.setLoadWithOverviewMode(true); // 縮放至屏幕的大小

        webSettings.setSupportZoom(true); //支持縮放,默認為true。是下麵那個的前提。
        webSettings.setBuiltInZoomControls(true); //設置內置的縮放控件。若為false,則該WebView不可縮放
        webSettings.setDisplayZoomControls(false); //隱藏原生的縮放控件

        webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); //關閉webview中緩存
        webSettings.setAllowFileAccess(true); //設置可以訪問文件
        webSettings.setJavaScriptCanOpenWindowsAutomatically(true); //支持通過JS打開新窗口
        webSettings.setLoadsImagesAutomatically(true); //支持自動加載圖片
        webSettings.setDefaultTextEncodingName("utf-8");//設置編碼格式

    }
 
開發者ID:DuanJiaNing,項目名稱:Musicoco,代碼行數:19,代碼來源:WebActivity.java

示例2: initSettings

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

    webSettings.setJavaScriptEnabled(true);

    webSettings.setDomStorageEnabled(true);
    webSettings.setAllowFileAccess(true);
    webSettings.setUseWideViewPort(true);

    webSettings.setUseWideViewPort(true);
    webSettings.setLoadWithOverviewMode(true);

    webSettings.setSupportZoom(false);
    webSettings.setBuiltInZoomControls(false);
    webSettings.setDisplayZoomControls(false);

    webSettings.setDefaultTextEncodingName("UTF-8");

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        webSettings.setAllowFileAccessFromFileURLs(true);
        webSettings.setAllowUniversalAccessFromFileURLs(true);
    }
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
        CookieManager cookieManager = CookieManager.getInstance();
        cookieManager.setAcceptThirdPartyCookies(this,true);
    }
    setWebViewDefaultCacheMode();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        webSettings.setMixedContentMode(
                WebSettings.MIXED_CONTENT_COMPATIBILITY_MODE);
    }
    setCachePath();

}
 
開發者ID:yale8848,項目名稱:CacheWebView,代碼行數:35,代碼來源:CacheWebView.java

示例3: setWebView

import android.webkit.WebSettings; //導入方法依賴的package包/類
private void setWebView()
{

    WebSettings webSettings = mWebView.getSettings();
    webSettings.setJavaScriptEnabled(true);//如果訪問的頁麵中要與Javascript交互,則webview必須設置支持Javascript
    webSettings.setUseWideViewPort(true); //將圖片調整到適合webview的大小
    webSettings.setLoadWithOverviewMode(true); // 縮放至屏幕的大小
    webSettings.setSupportZoom(true); //支持縮放,默認為true。是下麵那個的前提。
    webSettings.setBuiltInZoomControls(true); //設置內置的縮放控件。若為false,則該WebView不可縮放
    webSettings.setDisplayZoomControls(false); //隱藏原生的縮放控件
    webSettings.setAllowFileAccess(true); //設置可以訪問文件
    webSettings.setJavaScriptCanOpenWindowsAutomatically(true); //支持通過JS打開新窗口
    webSettings.setLoadsImagesAutomatically(true); //支持自動加載圖片
    webSettings.setDefaultTextEncodingName("utf-8");//設置編碼格式
    webSettings.setDomStorageEnabled(true);
    mWebView.setWebViewClient(new WebViewClient());
}
 
開發者ID:XndroidDev,項目名稱:Xndroid,代碼行數:18,代碼來源:WebViewFragment.java

示例4: setWebSettings

import android.webkit.WebSettings; //導入方法依賴的package包/類
private void setWebSettings() {
        WebSettings settings = mWebView.getSettings();
        settings.setJavaScriptEnabled(true);//開啟對JavaScript的支持
        settings.setDefaultTextEncodingName("UTF-8");//設置字符編碼
        settings.setSupportZoom(true);
        // 開啟alert
        settings.setJavaScriptCanOpenWindowsAutomatically(true);
        // 開啟按鈕按下顯示
        settings.setLightTouchEnabled(true);
//        settings.setUseWideViewPort(true);
        settings.setDomStorageEnabled(true);
        settings.setAppCacheEnabled(false);
        settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
        appendUserAgent("version", AppUtils.getNoPrefixVersionName(this));
        mWebView.requestFocus();
        mWebView.setWebChromeClient(chromeClient);
        mWebView.setWebViewClient(webViewClient);
    }
 
開發者ID:Jusenr,項目名稱:AppFirCloud,代碼行數:19,代碼來源:WebViewActivity.java

示例5: initViews

import android.webkit.WebSettings; //導入方法依賴的package包/類
private void initViews() {
        LayoutInflater.from(getContext()).inflate(R.layout.view_webview_default, this, true);
        mWebView = (MyWebView) findViewById(R.id.webview);
        mProgressBar = (ProgressBar) findViewById(R.id.progressbar);
        mProgressBar.setVisibility(VISIBLE);
        mWebView.setWebViewClient(new MyClient());
        mWebView.setWebChromeClient(new MyWebChromeClient());
        WebSettings webSettings = mWebView.getSettings();
//        webSettings.setJavaScriptCanOpenWindowsAutomatically(false);
        webSettings.setJavaScriptEnabled(true);
        webSettings.setRenderPriority(WebSettings.RenderPriority.HIGH);
//        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
//            webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
//        }
        webSettings.setBlockNetworkImage(true);
        mWebView.setOnScrollBottomListener(this);
//        mWebView.setLayerType(View.La, null);
//        mWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
//        mWebView.setVerticalScrollBarEnabled(true);
//        mWebView.setHorizontalScrollBarEnabled(false);
         webSettings.setSupportZoom(false);
//        webSettings.setBlockNetworkImage(true);
         webSettings.setDomStorageEnabled(true);
//        webSettings.setRenderPriority(WebSettings.RenderPriority.HIGH);
//        webSettings.setPluginState(WebSettings.PluginState.ON);
        webSettings.setDefaultTextEncodingName("UTF-8");
        webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
    }
 
開發者ID:SavorGit,項目名稱:Hotspot-master-devp,代碼行數:29,代碼來源:DefaultWebView.java

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

示例7: a

import android.webkit.WebSettings; //導入方法依賴的package包/類
public static void a(WebSettings webSettings) {
    webSettings.setJavaScriptEnabled(true);
    webSettings.setDefaultTextEncodingName(z[86]);
    webSettings.setSupportZoom(true);
    webSettings.setCacheMode(2);
    webSettings.setSaveFormData(false);
    webSettings.setSavePassword(false);
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:9,代碼來源:a.java

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

示例9: initView

import android.webkit.WebSettings; //導入方法依賴的package包/類
@SuppressLint("SetJavaScriptEnabled") private void initView(@Nullable AttributeSet attrs) {
    if (isInEditMode()) return;
    if (attrs != null) {
        TypedArray tp = getContext().obtainStyledAttributes(attrs, R.styleable.PrettifyWebView);
        try {
            int color = tp.getColor(R.styleable.PrettifyWebView_webview_background, ViewHelper.getWindowBackground(getContext()));
            setBackgroundColor(color);
        } finally {
            tp.recycle();
        }
    }
    setWebChromeClient(new ChromeClient());
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        setWebViewClient(new WebClient());
    } else {
        setWebViewClient(new WebClientCompat());
    }
    WebSettings settings = getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setAppCachePath(getContext().getCacheDir().getPath());
    settings.setAppCacheEnabled(true);
    settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
    settings.setDefaultTextEncodingName("utf-8");
    settings.setLoadsImagesAutomatically(true);
    settings.setBlockNetworkImage(false);
    setOnLongClickListener((view) -> {
        WebView.HitTestResult result = getHitTestResult();
        if (hitLinkResult(result) && !InputHelper.isEmpty(result.getExtra())) {
            AppHelper.copyToClipboard(getContext(), result.getExtra());
            return true;
        }
        return false;
    });
}
 
開發者ID:duyp,項目名稱:mvvm-template,代碼行數:35,代碼來源:PrettifyWebView.java

示例10: init

import android.webkit.WebSettings; //導入方法依賴的package包/類
@SuppressLint("SetJavaScriptEnabled")
private void init(AttributeSet attrs) {
    if (attrs != null) {
        TypedArray tp = getContext().obtainStyledAttributes(attrs, R.styleable.CodeWebView);
        try {
            backgroundColor = tp.getColor(R.styleable.CodeWebView_webview_background,
                    ViewUtils.getWindowBackground(getContext()));
            setBackgroundColor(backgroundColor);
        } finally {
            tp.recycle();
        }
    }

    setWebChromeClient(new ChromeClient());
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        setWebViewClient(new WebClientN());
    } else {
        setWebViewClient(new WebClient());
    }
    WebSettings settings = getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setAppCachePath(getContext().getCacheDir().getPath());
    settings.setAppCacheEnabled(true);
    settings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
    settings.setDefaultTextEncodingName("utf-8");
    settings.setLoadsImagesAutomatically(true);
    settings.setBlockNetworkImage(false);
    setOnLongClickListener(new OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            WebView.HitTestResult result = getHitTestResult();
            if (hitLinkResult(result) && !StringUtils.isBlank(result.getExtra())) {
                AppUtils.copyToClipboard(getContext(), result.getExtra());
                return true;
            }
            return false;
        }
    });
}
 
開發者ID:ThirtyDegreesRay,項目名稱:OpenHub,代碼行數:40,代碼來源:CodeWebView.java

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

示例12: init

import android.webkit.WebSettings; //導入方法依賴的package包/類
private void init(Context context) {
	mContext = context;
	mLayout = new FrameLayout(context);
	mBrowserFrameLayout = (FrameLayout) LayoutInflater.from(context)
			.inflate(R.layout.common_custom_screen, null);
	wv_imgbtn_back = (LinearLayout) mBrowserFrameLayout.findViewById(R.id.top_bar_linear_back);
	wv_tv_title = (TextView) mBrowserFrameLayout.findViewById(R.id.top_bar_title);
	mContentView = (FrameLayout) mBrowserFrameLayout
			.findViewById(R.id.main_content);
	mCustomViewContainer = (FrameLayout) mBrowserFrameLayout
			.findViewById(R.id.fullscreen_custom_content);
	frame_progress = (FrameLayout) mBrowserFrameLayout
			.findViewById(R.id.frame_progress);
	webview_tv_progress = (TextView) frame_progress
			.findViewById(R.id.webview_tv_progress);
	final FrameLayout.LayoutParams COVER_SCREEN_PARAMS = new FrameLayout.LayoutParams(
			ViewGroup.LayoutParams.MATCH_PARENT,
			ViewGroup.LayoutParams.MATCH_PARENT, Gravity.CENTER);
	mLayout.addView(mBrowserFrameLayout, COVER_SCREEN_PARAMS);
	mWebChromeClient = new MyWebChromeClient();
	setWebChromeClient(mWebChromeClient);
	setWebViewClient(new MyWebViewClient());
	WebSettings webSettings = this.getSettings();
	webSettings.setJavaScriptEnabled(true);  //開啟javascript
	webSettings.setDomStorageEnabled(true);  //開啟DOM
	webSettings.setDefaultTextEncodingName("utf-8"); //設置編碼
	// // web頁麵處理
	webSettings.setAllowFileAccess(true);// 支持文件流
	// webSettings.setSupportZoom(true);// 支持縮放
	// webSettings.setBuiltInZoomControls(true);// 支持縮放
	webSettings.setUseWideViewPort(true);// 調整到適合webview大小
	webSettings.setLoadWithOverviewMode(true);// 調整到適合webview大小
	webSettings.setDefaultZoom(ZoomDensity.FAR);// 屏幕自適應網頁,如果沒有這個,在低分辨率的手機上顯示可能會異常
	webSettings.setRenderPriority(RenderPriority.HIGH);
	//提高網頁加載速度,暫時阻塞圖片加載,然後網頁加載好了,在進行加載圖片
	webSettings.setBlockNetworkImage(true);
	//開啟緩存機製
	webSettings.setAppCacheEnabled(true);
	//根據當前網頁連接狀態
	 if(StrUtils.getAPNType(context)== StrUtils.WIFI){
	 //設置無緩存
	 webSettings.setCacheMode(WebSettings.LOAD_DEFAULT);
	 }else{
	 //設置緩存
	 webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
	 }
	mContentView.addView(this);
	// 返回
	wv_imgbtn_back.setOnClickListener(new OnClickListener() {
		@Override
		public void onClick(View v) {
			closeAdWebPage();
		}
	});
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:56,代碼來源:HTML5CustomWebView.java

示例13: 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());
	}


}
 
開發者ID:NewCasino,項目名稱:browser,代碼行數:43,代碼來源:LightningView.java

示例14: initSettings

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

    webSettings.setJavaScriptEnabled(true);

    webSettings.setDomStorageEnabled(true);
    webSettings.setAllowFileAccess(true);
    webSettings.setUseWideViewPort(true);

    webSettings.setUseWideViewPort(true);
    webSettings.setLoadWithOverviewMode(true);

    webSettings.setSupportZoom(false);
    webSettings.setBuiltInZoomControls(false);
    webSettings.setDisplayZoomControls(false);

    webSettings.setDefaultTextEncodingName("UTF-8");

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        webSettings.setAllowFileAccessFromFileURLs(true);
        webSettings.setAllowUniversalAccessFromFileURLs(true);
    }
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
        CookieManager cookieManager = CookieManager.getInstance();
        cookieManager.setAcceptThirdPartyCookies(mWebView,true);
    }
   if (NetworkUtils.isConnected(mWebView.getContext()) ){
        webSettings.setCacheMode(WebSettings.LOAD_DEFAULT);
    } else {
        webSettings.setCacheMode(
                WebSettings.LOAD_CACHE_ELSE_NETWORK);
    }



    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        webSettings.setMixedContentMode(
                WebSettings.MIXED_CONTENT_COMPATIBILITY_MODE);
    }
    setCachePath();

}
 
開發者ID:yale8848,項目名稱:CacheWebView,代碼行數:43,代碼來源:Main2Activity.java

示例15: setWebView

import android.webkit.WebSettings; //導入方法依賴的package包/類
/**
 * 配置webView
 */
void setWebView() {
    //聲明WebSettings子類
    WebSettings webSettings = mWebView.getSettings();

    //支持Javascript交互
    webSettings.setJavaScriptEnabled(true);


    //設置自適應屏幕,兩者合用
    webSettings.setUseWideViewPort(true); //將圖片調整到適合webview的大小
    webSettings.setLoadWithOverviewMode(true); // 縮放至屏幕的大小

    //縮放操作
    webSettings.setSupportZoom(true); //支持縮放,默認為true。是下麵那個的前提。
    webSettings.setBuiltInZoomControls(true); //設置內置的縮放控件。若為false,則該WebView不可縮放
    webSettings.setDisplayZoomControls(false); //隱藏原生的縮放控件

    //其他細節操作
    //webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); //關閉webview中緩存
    webSettings.setAllowFileAccess(true); //設置可以訪問文件

    //對於不需要使用 file 協議的應用,禁用 file 協議;防止文件泄密,file協議即是file://
    //webSettings.setAllowFileAccess(false);
    //webSettings.setAllowFileAccessFromFileURLs(false);
    //webSettings.setAllowUniversalAccessFromFileURLs(false);



    webSettings.setJavaScriptCanOpenWindowsAutomatically(true); //支持通過JS打開新窗口
    webSettings.setLoadsImagesAutomatically(true); //支持自動加載圖片
    webSettings.setDefaultTextEncodingName("utf-8");//設置編碼格式

    mWebView.setDownloadListener(new DownloadListener() {
        @Override
        public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
            //網頁中觸發下載動作
        }
    });

    //增加js交互接口
    mWebView.addJavascriptInterface(new JsCallAndroidInterface(), "JSCallBackInterface");
}
 
開發者ID:CarGuo,項目名稱:CustomActionWebView,代碼行數:46,代碼來源:APIWebViewActivity.java


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