android.webkit.WebSettings Java Examples
The following examples show how to use
android.webkit.WebSettings.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PNDVActivity.java From PressureNet with GNU General Public License v3.0 | 6 votes |
public void loadPNDV() { WebView pndvWebView = (WebView) findViewById(R.id.webViewPNDV); WebSettings webSettings = pndvWebView.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setBuiltInZoomControls(true); Intent intent = getIntent(); double latitude = intent.getDoubleExtra("latitude",0.0); double longitude = intent.getDoubleExtra("longitude", 0.0); Calendar cal = Calendar.getInstance(); long now = cal.getTimeInMillis(); long dayInMillis = 1000*60*60*24; long twoDaysAgo = cal.getTimeInMillis() - (2 * dayInMillis); // gotta use tomorrow for UTC hack long tomorrow = now + dayInMillis; if(latitude!=0){ pndvWebView.loadUrl(CbConfiguration.SERVER_URL_PRESSURENET + "?event=true&latitude=" + latitude + "&longitude=" + longitude + "&startTime=" + twoDaysAgo + "&endTime=" + tomorrow + "&zoomLevel=10"); } else { pndvWebView.loadUrl(CbConfiguration.SERVER_URL_PRESSURENET); } }
Example #2
Source File: Web3View.java From alpha-wallet-android with MIT License | 6 votes |
@SuppressLint("SetJavaScriptEnabled") public void init() { jsInjectorClient = new JsInjectorClient(getContext()); webViewClient = new Web3ViewClient(jsInjectorClient, new UrlHandlerManager()); WebSettings webSettings = getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setCacheMode(WebSettings.LOAD_DEFAULT); webSettings.setBuiltInZoomControls(true); webSettings.setDisplayZoomControls(false); webSettings.setUseWideViewPort(true); webSettings.setLoadWithOverviewMode(true); webSettings.setDomStorageEnabled(true); webSettings.setJavaScriptCanOpenWindowsAutomatically(true); webSettings.setUserAgentString(webSettings.getUserAgentString() + "AlphaWallet(Platform=Android&AppVersion=" + BuildConfig.VERSION_NAME + ")"); WebView.setWebContentsDebuggingEnabled(true); //so devs can debug their scripts/pages addJavascriptInterface(new SignCallbackJSInterface( this, innerOnSignTransactionListener, innerOnSignMessageListener, innerOnSignPersonalMessageListener, innerOnSignTypedMessageListener), "alpha"); }
Example #3
Source File: DetailFragment.java From WanAndroid with Apache License 2.0 | 6 votes |
private void loadUrl(String url){ agentWeb = AgentWeb.with(this) .setAgentWebParent(webViewContainer, new FrameLayout.LayoutParams(-1, -1)) .useDefaultIndicator() .createAgentWeb() .ready() .go(url); WebView webView = agentWeb.getWebCreator().getWebView(); WebSettings settings = webView.getSettings(); settings.setJavaScriptEnabled(true); settings.setSupportZoom(true); settings.setBuiltInZoomControls(true); settings.setDisplayZoomControls(false); settings.setUseWideViewPort(true); settings.setLoadsImagesAutomatically(true); settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN); }
Example #4
Source File: WebViewActivity.java From Tok-Android with GNU General Public License v3.0 | 6 votes |
private void initSetting() { WebSettings settings = mWebView.getSettings(); settings.setAppCacheEnabled(false); settings.setCacheMode(WebSettings.LOAD_NO_CACHE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { WebView.setWebContentsDebuggingEnabled(true); } String userAgent = settings.getUserAgentString(); settings.setUserAgentString( userAgent + " TokAndroid/" + String.valueOf(BuildConfig.VERSION_NAME)); settings.setJavaScriptEnabled(true); settings.setAllowFileAccessFromFileURLs(false); settings.setAllowUniversalAccessFromFileURLs(false); settings.setDomStorageEnabled(true); settings.setAllowFileAccess(true); settings.setAppCacheEnabled(true); settings.setCacheMode(WebSettings.LOAD_DEFAULT); settings.setDatabaseEnabled(true); settings.setSupportZoom(true); settings.setBuiltInZoomControls(true); settings.setDisplayZoomControls(false); settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN); settings.setUseWideViewPort(true); settings.setLoadWithOverviewMode(true); }
Example #5
Source File: FullScreenWebViewDialog.java From VideoOS-Android-SDK with GNU General Public License v3.0 | 6 votes |
private void buildSetting(WebView webView) { webView.clearCache(true); webView.clearHistory(); WebSettings webSettings = webView.getSettings(); webSettings.setJavaScriptCanOpenWindowsAutomatically(true); webSettings.setDefaultTextEncodingName("utf-8");// 避免中文乱码 webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL); webSettings.setJavaScriptEnabled(true); webSettings.setNeedInitialFocus(false); // webSettings.setDatabaseEnabled(true); webSettings.setDomStorageEnabled(true); // webSettings.setBlockNetworkLoads(true); webSettings.setJavaScriptCanOpenWindowsAutomatically(true); webSettings.setRenderPriority(WebSettings.RenderPriority.HIGH);//1、提高渲染的优先级 // webSettings.setBlockNetworkImage(true);//把图片加载放在最后来加载渲染 webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE); webSettings.setSupportZoom(false); }
Example #6
Source File: YouTubePlayerWebView.java From android-inline-youtube-view with Apache License 2.0 | 6 votes |
/** * Initialises YoutubeWebView with given videoId and youtubeListener */ @SuppressLint("SetJavaScriptEnabled") private void initWebView(String webViewUrl) { WebSettings set = this.getSettings(); set.setJavaScriptEnabled(true); set.setUseWideViewPort(true); set.setLoadWithOverviewMode(true); set.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL); set.setCacheMode(WebSettings.LOAD_DEFAULT); set.setPluginState(WebSettings.PluginState.ON_DEMAND); set.setAllowContentAccess(true); set.setAllowFileAccess(false); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { set.setMediaPlaybackRequiresUserGesture(false); } this.setLayerType(View.LAYER_TYPE_NONE, null); this.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED); this.loadUrl(webViewUrl); if (BuildConfig.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { setWebContentsDebuggingEnabled(true); } this.setWebViewClient(initWebViewClient()); }
Example #7
Source File: EasyBridgeWebView.java From EasyBridge with MIT License | 6 votes |
@SuppressLint({"SetJavaScriptEnabled", "AddJavascriptInterface"}) private void initWebView() { // 开启JavaScript的支持 WebSettings webSettings = getSettings(); if (webSettings != null) { webSettings.setJavaScriptEnabled(true); } addJavascriptInterface(easyBridge, MAPPING_JS_INTERFACE_NAME); EasyBridgeWebChromeClient webChromeClient = new EasyBridgeWebChromeClient(this); setWebChromeClient(webChromeClient); //register a default handler to subscribe the event of bridge injected registerHandler(new BaseBridgeHandler(REGISTER_INJECT_FINISHED, this) { @Override public void onCall(String parameters, ResultCallBack callBack) { Logger.debug("inject bridge success in page:" + getUrl()); if (listener != null) { listener.onInjected(); } setInjected(true); } }); }
Example #8
Source File: ArticleActivity.java From WanAndroid with Apache License 2.0 | 6 votes |
@Override protected void initData() { super.initData(); mAgentWeb = AgentWeb.with(this) .setAgentWebParent(flContainer, new LinearLayout.LayoutParams(-1, -1)) .useDefaultIndicator(getResources().getColor(R.color.colorPrimary)) .setMainFrameErrorView(R.layout.error_view, -1) .setWebLayout(new WebLayout(this)) .setOpenOtherPageWays(DefaultWebClient.OpenOtherPageWays.ASK) .createAgentWeb() .ready() .go(mAddress); //得到WebView WebView webView = mAgentWeb.getWebCreator().getWebView(); WebSettings settings = webView.getSettings(); setSettings(settings); //得到AgentWeb最底层的控件 FrameLayout frameLayout = mAgentWeb.getWebCreator().getWebParentLayout(); addBgChild(frameLayout); }
Example #9
Source File: SimpleWebViewActivity.java From android-test with Apache License 2.0 | 6 votes |
@Override public void onCreate(Bundle icicle) { super.onCreate(icicle); WebView mainWebView = new WebView(this); setContentView(mainWebView); mainWebView.loadData( "<html>" + "<script>document.was_clicked = false</script>" + "<body> " + "<button style='height:1000px;width:1000px;' onclick='document.was_clicked = true'> " + "I'm a button</button>" + "</body> " + "</html>", "text/html", null); WebSettings settings = mainWebView.getSettings(); settings.setJavaScriptEnabled(true); }
Example #10
Source File: GoogleRecaptchaVerifyActivity.java From v9porn with MIT License | 6 votes |
private void initWebView() { WebSettings mWebSettings = webView.getSettings(); //启用JavaScript。 mWebSettings.setJavaScriptEnabled(true); mWebSettings.setUseWideViewPort(true); mWebSettings.setJavaScriptCanOpenWindowsAutomatically(true); cookieManager = CookieManager.getInstance(); webView.setWebViewClient(new MyWebClient()); webView.setWebChromeClient(new WebChromeClient() { @Override public void onProgressChanged(WebView view, int newProgress) { if (newProgress == 100) { loadVerifyPageSuccess(); } super.onProgressChanged(view, newProgress); } }); cookieManager.setAcceptThirdPartyCookies(webView, true); if (BuildConfig.DEBUG) { WebView.setWebContentsDebuggingEnabled(true); } }
Example #11
Source File: PadViewActivity.java From padland with Apache License 2.0 | 6 votes |
/** * Enables the required settings and features for the webview * * @param webView */ private void _makeWebSettings(WebView webView) { webView.setInitialScale(1); WebSettings webSettings = webView.getSettings(); // Enable Javascript webSettings.setJavaScriptEnabled(true); // remove a weird white line on the right size webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY); webSettings.setUseWideViewPort(true); webSettings.setSupportZoom(true); webSettings.setBuiltInZoomControls(true); webSettings.setDisplayZoomControls(false); webSettings.setLoadWithOverviewMode(true); webSettings.setDomStorageEnabled(true); // Required for some NodeJS based code }
Example #12
Source File: WebViewActivity.java From V2EX with GNU General Public License v3.0 | 6 votes |
@SuppressLint("SetJavaScriptEnabled") @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.act_web_view); mWebView = find(R.id.webView); mWebView.setNetworkAvailable(true); WebSettings webSettings = mWebView.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setSupportZoom(true); mWebView.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } }); mWebView.loadUrl(getIntent().getStringExtra("url")); }
Example #13
Source File: ThreadViewFragment.java From something.apk with MIT License | 6 votes |
@SuppressLint({"SetJavaScriptEnabled", "AddJavascriptInterface", "NewApi"}) private void initWebview() { threadView.getSettings().setJavaScriptEnabled(true); threadView.setWebChromeClient(chromeClient); threadView.setWebViewClient(webClient); threadView.addJavascriptInterface(new SomeJavascriptInterface(), "listener"); if (Constants.DEBUG && SomeUtils.isKitKat()) { WebView.setWebContentsDebuggingEnabled(true); } if (SomeUtils.isLollipop()) { threadView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); } if (SomeUtils.isJellybean()) { threadView.getSettings().setAllowUniversalAccessFromFileURLs(true); threadView.getSettings().setAllowFileAccessFromFileURLs(true); threadView.getSettings().setAllowFileAccess(true); threadView.getSettings().setAllowContentAccess(true); } threadView.setBackgroundColor(SomeTheme.getThemeColor(getActivity(), R.attr.webviewBackgroundColor, Color.BLACK)); registerForContextMenu(threadView); }
Example #14
Source File: WebViewActivity.java From AndroidSamples with Apache License 2.0 | 6 votes |
private void initWeb() { WebSettings webSettings = mWebView.getSettings(); // 启用js webSettings.setJavaScriptEnabled(true); // 禁止缩放 webSettings.setBuiltInZoomControls(false); webSettings.setSupportZoom(false); //不显示webview缩放按钮 webSettings.setDisplayZoomControls(false); // WebView 背景透明效果 // webview.setBackgroundColor(Color.TRANSPARENT); mWebView.addJavascriptInterface(new JsInteration(), "app"); mWebView.loadUrl("file:///android_asset/html/webtest.html"); }
Example #15
Source File: WebActivity.java From GankGirl with GNU Lesser General Public License v2.1 | 6 votes |
@Override protected void initView() { mUrl = getIntent().getStringExtra(Constants.EXTRA_URL); mTitle = getIntent().getStringExtra(Constants.EXTRA_TITLE); getToolbar().setTitle(mUrl); WebSettings ws = webView.getSettings(); ws.setJavaScriptEnabled(true); ws.setLoadWithOverviewMode(true); ws.setAppCacheEnabled(true); ws.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN); ws.setSupportZoom(true); webView.setWebChromeClient(new webChromeClient()); webView.setWebViewClient(new webViewClient()); webView.loadUrl(mUrl); }
Example #16
Source File: InstagramLoginActivity.java From InstagramPhotoPicker-Android with MIT License | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_instagram_login); this.clientId = getIntent().getStringExtra(EXTRA_CLIENT_ID); this.redirectUri = getIntent().getStringExtra(EXTRA_REDIRECT_URI); webview = (WebView) findViewById(R.id.webview); WebSettings webSettings = webview.getSettings(); webSettings.setJavaScriptEnabled(true); webview.setWebViewClient(webViewClient); loadLoginPage(); }
Example #17
Source File: WebPlayerView.java From unity-ads-android with Apache License 2.0 | 5 votes |
public void setSettings (JSONObject webSettings, JSONObject webPlayerSettings) { if (_erroredSettings != null) { _erroredSettings.clear(); } WebSettings settings = getSettings(); setTargetSettings(settings, webSettings); setTargetSettings(this, webPlayerSettings); }
Example #18
Source File: BaseActivity.java From ZhihuDaily with Apache License 2.0 | 5 votes |
private void initWebView() { WebSettings settings = mWebView.getSettings(); settings.setJavaScriptEnabled(true); settings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); settings.setLoadWithOverviewMode(true); settings.setBuiltInZoomControls(true); settings.setDomStorageEnabled(true); settings.setDatabaseEnabled(true); settings.setSupportZoom(false); settings.setAppCachePath(getCacheDir().getAbsolutePath() + "/webViewCache"); settings.setAppCacheEnabled(true); settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN); mWebView.setWebChromeClient(new WebChromeClient()); }
Example #19
Source File: ResultsActivity.java From ZbarCode with Apache License 2.0 | 5 votes |
private void loadUrl() { mWebView.loadUrl(mResult); WebSettings settings = mWebView.getSettings(); settings.setUseWideViewPort(true); settings.setLoadWithOverviewMode(true); settings.setJavaScriptEnabled(true); // 设置setWebChromeClient对象 mWebView.setWebChromeClient(wvcc); mWebView.setWebViewClient(wvc); }
Example #20
Source File: MainFragment.java From chromium-webview-samples with Apache License 2.0 | 5 votes |
/** * Convenience method to set some generic defaults for a * given WebView * * @param webView */ @TargetApi(Build.VERSION_CODES.HONEYCOMB) private void setUpWebViewDefaults(WebView webView) { WebSettings settings = webView.getSettings(); // Enable Javascript settings.setJavaScriptEnabled(true); // Use WideViewport and Zoom out if there is no viewport defined settings.setUseWideViewPort(true); settings.setLoadWithOverviewMode(true); // Enable pinch to zoom without the zoom buttons settings.setBuiltInZoomControls(true); if(Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB) { // Hide the zoom controls for HONEYCOMB+ settings.setDisplayZoomControls(false); } // Enable remote debugging via chrome://inspect if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { WebView.setWebContentsDebuggingEnabled(true); } // We set the WebViewClient to ensure links are consumed by the WebView rather // than passed to a browser if it can mWebView.setWebViewClient(new WebViewClient()); }
Example #21
Source File: SnsPreviewActivity.java From samples with Apache License 2.0 | 5 votes |
@SuppressLint("SetJavaScriptEnabled") private void settingWebView() { WebSettings settings = webView.getSettings(); settings.setJavaScriptEnabled(true); settings.setMinimumFontSize(16); settings.setLoadWithOverviewMode(true); settings.setUseWideViewPort(false); settings.setDatabaseEnabled(true); settings.setAppCacheEnabled(true); settings.setCacheMode(WebSettings.LOAD_DEFAULT); //设置 缓存模式 // 开启 DOM storage API 功能 settings.setDomStorageEnabled(true); }
Example #22
Source File: AdBlocksWebViewActivity.java From AdBlockedWebView-Android with MIT License | 5 votes |
@SuppressLint("SetJavaScriptEnabled") private void bindView() { // Toolbar mTvTitle = (TextView) findViewById(R.id.toolbar_tv_title); mTvUrl = (TextView) findViewById(R.id.toolbar_tv_url); findViewById(R.id.toolbar_root).setBackgroundColor(getIntent().getIntExtra(EXTRA_COLOR, Color.BLACK)); mCoordinatorLayout = (CoordinatorLayout) findViewById(R.id.a_web_viewer_coordinatorlayout); mProgressBar = (ProgressBar) findViewById(R.id.a_web_viewer_pb); mSwipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.a_web_viewer_srl); mWebView = (WebView) findViewById(R.id.a_web_viewer_wv); mSwipeRefreshLayout.setOnRefreshListener(this); WebSettings webSettings = mWebView.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setJavaScriptCanOpenWindowsAutomatically(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { webSettings.setDisplayZoomControls(false); } webSettings.setBuiltInZoomControls(true); webSettings.setSupportZoom(true); webSettings.setDomStorageEnabled(true); mWebView.setWebChromeClient(new MyWebChromeClient()); mWebView.setWebViewClient(new MyWebViewClient()); mWebView.setDownloadListener(this); mWebView.setOnCreateContextMenuListener(this); mBtnMore = (AppCompatImageButton) findViewById(R.id.toolbar_btn_more); //noinspection ConstantConditions findViewById(R.id.toolbar_btn_close).setOnClickListener(this); //noinspection ConstantConditions mBtnMore.setOnClickListener(this); // PopupWindow initPopupMenu(); }
Example #23
Source File: CacheableWebView.java From materialistic with Apache License 2.0 | 5 votes |
private String getCacheableUrl(String url) { if (TextUtils.equals(url, BLANK) || TextUtils.equals(url, FILE)) { return url; } mArchiveClient.cacheFileName = generateCacheFilename(url); setCacheModeInternal(); if (getSettings().getCacheMode() != WebSettings.LOAD_CACHE_ONLY) { return url; } File cacheFile = new File(mArchiveClient.cacheFileName); return cacheFile.exists() ? Uri.fromFile(cacheFile).toString() : url; }
Example #24
Source File: MarkdownView.java From diycode with Apache License 2.0 | 5 votes |
@SuppressLint({"AddJavascriptInterface", "SetJavaScriptEnabled"}) public MarkdownView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); if (isInEditMode()) { return; } WebSettings settings = getSettings(); settings.setJavaScriptEnabled(true); settings.setDomStorageEnabled(true); settings.setDatabaseEnabled(true); initialize(); }
Example #25
Source File: BaseWebActivity.java From Aurora with Apache License 2.0 | 5 votes |
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); }
Example #26
Source File: HuPuWebView.java From SprintNBA with Apache License 2.0 | 5 votes |
private void init() { WebSettings settings = getSettings(); settings.setBuiltInZoomControls(false); settings.setSupportZoom(false); settings.setJavaScriptEnabled(true); settings.setAllowFileAccess(true); settings.setSupportMultipleWindows(false); settings.setJavaScriptCanOpenWindowsAutomatically(true); settings.setDomStorageEnabled(true); settings.setCacheMode(WebSettings.LOAD_DEFAULT); settings.setUseWideViewPort(true); if (Build.VERSION.SDK_INT > 6) { settings.setAppCacheEnabled(true); settings.setLoadWithOverviewMode(true); } String path = getContext().getFilesDir().getPath(); settings.setGeolocationEnabled(true); settings.setGeolocationDatabasePath(path); settings.setDomStorageEnabled(true); this.basicUA = settings.getUserAgentString() + " kanqiu/7.05.6303/7059"; setBackgroundColor(0); initWebViewClient(); setWebChromeClient(new HuPuChromeClient()); try { if (SettingPrefUtils.isLogin()) { CookieManager cookieManager = CookieManager.getInstance(); cookieManager.setCookie("http://bbs.mobileapi.hupu.com", "u=" + SettingPrefUtils.getCookies()); cookieManager.setCookie("http://bbs.mobileapi.hupu.com", "_gamesu=" + URLEncoder.encode(SettingPrefUtils.getToken(), "utf-8")); cookieManager.setCookie("http://bbs.mobileapi.hupu.com", "_inKanqiuApp=1"); cookieManager.setCookie("http://bbs.mobileapi.hupu.com", "_kanqiu=1"); CookieSyncManager.getInstance().sync(); } } catch (Exception e) { e.printStackTrace(); } }
Example #27
Source File: InnerFastClient.java From FastWebView with MIT License | 5 votes |
InnerFastClient(FastWebView owner) { mOwner = owner; WebSettings settings = owner.getSettings(); mWebViewCacheMode = settings.getCacheMode(); mUserAgent = settings.getUserAgentString(); mWebViewCache = new WebViewCacheImpl(owner.getContext()); }
Example #28
Source File: BaseWebView.java From dcs-sdk-java with Apache License 2.0 | 5 votes |
@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()); }
Example #29
Source File: ShinnyTechActivity.java From shinny-futures-android with GNU General Public License v3.0 | 5 votes |
@Override protected void initData() { mBinding = (ActivityShinnyTechBinding) mViewDataBinding; WebSettings settings = mBinding.webView.getSettings(); settings.setDomStorageEnabled(true); settings.setJavaScriptEnabled(true); //设置WebView属性,运行执行js脚本 settings.setUseWideViewPort(true);//将图片调整到适合webView的大小 settings.setLoadWithOverviewMode(true); //自适应屏幕 settings.setBuiltInZoomControls(true); settings.setDisplayZoomControls(false); settings.setSupportZoom(true);//设定支持缩放 settings.setDefaultTextEncodingName("utf-8"); settings.setLoadsImagesAutomatically(true); mBinding.webView.loadUrl("https://www.shinnytech.com/q/");//调用loadUrl方法为WebView加入链接 }
Example #30
Source File: CodeActivity.java From WeGit with Apache License 2.0 | 5 votes |
@Override public void setCode(String content) { L.i(TAG, "setCode = " + content); this.content = content; WebSettings settings = webview.getSettings(); settings.setBuiltInZoomControls(true); settings.setJavaScriptEnabled(true); webview.addJavascriptInterface(new JavaScriptInterface(), "bitbeaker"); webview.loadUrl("file:///android_asset/source.html"); }