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


Java WebSettings.setDomStorageEnabled方法代碼示例

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


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

示例1: writeEncryToken

import android.webkit.WebSettings; //導入方法依賴的package包/類
@SuppressLint({"SetJavaScriptEnabled"})
public void writeEncryToken(Context context) {
    String str = "tencent&sdk&qazxc***14969%%";
    String accessToken = this.mToken.getAccessToken();
    String appId = this.mToken.getAppId();
    String openId = this.mToken.getOpenId();
    String str2 = "qzone3.4";
    if (accessToken == null || accessToken.length() <= 0 || appId == null || appId.length() <= 0 || openId == null || openId.length() <= 0) {
        str = null;
    } else {
        str = Util.encrypt(str + accessToken + appId + openId + str2);
    }
    com.tencent.open.c.b bVar = new com.tencent.open.c.b(context);
    WebSettings settings = bVar.getSettings();
    settings.setDomStorageEnabled(true);
    settings.setJavaScriptEnabled(true);
    settings.setDatabaseEnabled(true);
    accessToken = "<!DOCTYPE HTML><html lang=\"en-US\"><head><meta charset=\"UTF-8\"><title>localStorage Test</title><script type=\"text/javascript\">document.domain = 'qq.com';localStorage[\"" + this.mToken.getOpenId() + EventsFilesManager.ROLL_OVER_FILE_NAME_SEPARATOR + this.mToken.getAppId() + "\"]=\"" + str + "\";</script></head><body></body></html>";
    str = ServerSetting.getInstance().getEnvUrl(context, ServerSetting.DEFAULT_LOCAL_STORAGE_URI);
    bVar.loadDataWithBaseURL(str, accessToken, "text/html", "utf-8", str);
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:22,代碼來源:SocialApiIml.java

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

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

示例6: initWebView

import android.webkit.WebSettings; //導入方法依賴的package包/類
private void initWebView() {
    final WebSettings webSettings = webView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setDomStorageEnabled(true); // needed for FxA login.
    webView.setWebViewClient(new ScriptInjectionWebViewClient(script));

    final String userAgent = FirefoxDataRequestUtils.getUserAgent(applicationName, DeviceUtils.isTablet());
    webSettings.setUserAgentString(userAgent);

    // It's recommended JS interface is used on SDK min 17+ because on earlier versions the
    // page's JS can use reflection to call Java methods. However, since we trust the page,
    // we shouldn't be vulnerable.
    webView.addJavascriptInterface(new JSInterface(), JS_INTERFACE_OBJ);
    webView.loadUrl(webViewURL);
}
 
開發者ID:mozilla-mobile,項目名稱:FirefoxData-android,代碼行數:16,代碼來源:FirefoxDataWebViewLoginActivity.java

示例7: init

import android.webkit.WebSettings; //導入方法依賴的package包/類
@SuppressLint("SetJavaScriptEnabled")
private void init() {
    final WebSettings settings = getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setCacheMode(WebSettings.LOAD_DEFAULT);
    settings.setDomStorageEnabled(true);
    settings.setDatabaseEnabled(true);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        settings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
    }

    mWebViewClient = new HubsWebViewClient();
    setWebViewClient(mWebViewClient);
}
 
開發者ID:nekocode,項目名稱:Hubs,代碼行數:16,代碼來源:HubsWebView.java

示例8: initModule

import android.webkit.WebSettings; //導入方法依賴的package包/類
public void initModule(Context context, c cVar) {
    m mVar = (m) cVar;
    CharSequence charSequence = mVar.E;
    setFocusable(true);
    this.mWebView = (WebView) findViewById(getResources().getIdentifier(z[3], z[2], context.getPackageName()));
    this.rlTitleBar = (RelativeLayout) findViewById(getResources().getIdentifier(z[5], z[2], context.getPackageName()));
    this.tvTitle = (TextView) findViewById(getResources().getIdentifier(z[8], z[2], context.getPackageName()));
    this.imgBtnBack = (ImageButton) findViewById(getResources().getIdentifier(z[1], z[2], context.getPackageName()));
    if (this.mWebView == null || this.rlTitleBar == null || this.tvTitle == null || this.imgBtnBack == null) {
        z.e(TAG, z[7]);
        ((Activity) this.mContext).finish();
    }
    if (1 == mVar.G) {
        this.rlTitleBar.setVisibility(8);
        ((Activity) context).getWindow().setFlags(1024, 1024);
    } else {
        this.tvTitle.setText(charSequence);
        this.imgBtnBack.setOnClickListener(this.btnBackClickListener);
    }
    this.mWebView.setScrollbarFadingEnabled(true);
    this.mWebView.setScrollBarStyle(33554432);
    WebSettings settings = this.mWebView.getSettings();
    settings.setDomStorageEnabled(true);
    a.a(settings);
    webViewHelper = new f(context, cVar);
    this.mWebView.removeJavascriptInterface(z[6]);
    this.mWebView.setWebChromeClient(new cn.jpush.android.b.a.a(z[4], b.class));
    this.mWebView.setWebViewClient(new c(cVar));
    b.setWebViewHelper(webViewHelper);
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:31,代碼來源:FullScreenView.java

示例9: b

import android.webkit.WebSettings; //導入方法依賴的package包/類
@SuppressLint({"SetJavaScriptEnabled"})
private void b() {
    this.i.setVerticalScrollBarEnabled(false);
    this.i.setHorizontalScrollBarEnabled(false);
    this.i.setWebViewClient(new FbWebViewClient());
    this.i.setWebChromeClient(this.mChromeClient);
    this.i.clearFormData();
    WebSettings settings = this.i.getSettings();
    settings.setSavePassword(false);
    settings.setSaveFormData(false);
    settings.setCacheMode(-1);
    settings.setNeedInitialFocus(false);
    settings.setBuiltInZoomControls(true);
    settings.setSupportZoom(true);
    settings.setRenderPriority(RenderPriority.HIGH);
    settings.setJavaScriptEnabled(true);
    if (!(this.c == null || this.c.get() == null)) {
        settings.setDatabaseEnabled(true);
        settings.setDatabasePath(((Context) this.c.get()).getApplicationContext().getDir("databases", 0).getPath());
    }
    settings.setDomStorageEnabled(true);
    this.jsBridge.a(new JsListener(), "sdk_js_if");
    this.i.loadUrl(this.e);
    this.i.setLayoutParams(a);
    this.i.setVisibility(4);
    this.i.getSettings().setSavePassword(false);
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:28,代碼來源:TDialog.java

示例10: setupWebView

import android.webkit.WebSettings; //導入方法依賴的package包/類
private void setupWebView(WebSettings settings) {
    if (settings == null) {
        return;
    }

    settings.setAppCacheEnabled(true);
    settings.setAllowFileAccess(true);
    settings.setJavaScriptEnabled(true);
    settings.setDomStorageEnabled(true);
    settings.setJavaScriptCanOpenWindowsAutomatically(true);
    settings.setSupportZoom(true);
    settings.setDisplayZoomControls(true);
}
 
開發者ID:Sugarya,項目名稱:FragmentCapsulation,代碼行數:14,代碼來源:BasicWebFragmentWithToolBar.java

示例11: init

import android.webkit.WebSettings; //導入方法依賴的package包/類
private void init() {
    WebSettings settings = getSettings();
    settings.setUseWideViewPort(true);
    settings.setBuiltInZoomControls(true);
    settings.setLoadWithOverviewMode(true);
    settings.setJavaScriptEnabled(true);
    settings.setJavaScriptCanOpenWindowsAutomatically(true);
    settings.setDomStorageEnabled(true);
    settings.setDisplayZoomControls(false);
    setWebViewClient(new WebViewClient());
    setWebChromeClient(new WebChromeClient());
}
 
開發者ID:hyb1996,項目名稱:Auto.js,代碼行數:13,代碼來源:JsWebView.java

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

示例13: WebViewTask

import android.webkit.WebSettings; //導入方法依賴的package包/類
public WebViewTask(Context context) {
    webView = new WebView(context);
    webView.addJavascriptInterface(new InJavaScriptLocalObj(), "get_source");
    webView.setWebViewClient(new WebViewClient() {
        @Override
        public void onPageFinished(WebView view, String url) {
            webView.loadUrl("javascript:window.get_source.getSource('<head>'+document.getElementsByTagName('html')[0].innerHTML+'</head>');");
        }
    });
    WebSettings webSettings = webView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setDomStorageEnabled(true);
    webSettings.setBlockNetworkImage(true);
    webSettings.setUserAgentString("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.109 Safari/537.36");
}
 
開發者ID:lanyuanxiaoyao,項目名稱:PicKing,代碼行數:16,代碼來源:WebViewTask.java

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

示例15: initWebView

import android.webkit.WebSettings; //導入方法依賴的package包/類
private void initWebView() {
    WebSettings ws = mWebView.getSettings();
    // 網頁內容的寬度是否可大於WebView控件的寬度
    ws.setLoadWithOverviewMode(false);
    // 保存表單數據
    ws.setSaveFormData(true);
    // 是否應該支持使用其屏幕縮放控件和手勢縮放
    ws.setSupportZoom(true);
    ws.setBuiltInZoomControls(true);
    ws.setDisplayZoomControls(false);
    // 啟動應用緩存
    ws.setAppCacheEnabled(true);
    // 設置緩存模式
    ws.setCacheMode(WebSettings.LOAD_DEFAULT);
    // setDefaultZoom  api19被棄用
    // 設置此屬性,可任意比例縮放。
    ws.setUseWideViewPort(true);
    // 縮放比例 1
    mWebView.setInitialScale(1);
    // 告訴WebView啟用JavaScript執行。默認的是false。
    ws.setJavaScriptEnabled(true);
    //  頁麵加載好以後,再放開圖片
    ws.setBlockNetworkImage(false);
    // 使用localStorage則必須打開
    ws.setDomStorageEnabled(true);
    // 排版適應屏幕
    ws.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
    // WebView是否支持多個窗口。
    ws.setSupportMultipleWindows(true);
    // webview從5.0開始默認不允許混合模式,https中不能加載http資源,需要設置開啟。
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        ws.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
    }
    /** 設置字體默認縮放大小(改變網頁字體大小,setTextSize  api14被棄用)*/
    ws.setTextZoom(100);
    mWebView.setWebViewClient(new MyWebViewClient());
    mWebView.setWebChromeClient(webChromeClient = new MyWebChromeClient());
    mWebView.loadUrl(url);
}
 
開發者ID:yangchong211,項目名稱:YCUtils,代碼行數:40,代碼來源:KnowledgeOtherFragment.java


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