List of usage examples for android.webkit WebSettings setAppCacheEnabled
public abstract void setAppCacheEnabled(boolean flag);
From source file:net.niyonkuru.koodroid.webview.BlockingWebView.java
public static BlockingWebView createInstance(Context ctx) { BlockingWebView view = new BlockingWebView(ctx); WebSettings websettings = view.getSettings(); websettings.setJavaScriptEnabled(true); websettings.setDatabaseEnabled(false); websettings.setDomStorageEnabled(false); websettings.setSupportZoom(false);//from w w w . jav a 2 s . c o m websettings.setSavePassword(false); websettings.setSupportMultipleWindows(false); websettings.setAppCacheEnabled(false); websettings.setCacheMode(WebSettings.LOAD_NO_CACHE); websettings.setBlockNetworkImage(true); return view; }
From source file:com.chatwing.whitelabel.fragments.ProfileInfoFragment.java
private void configWebView(WebView webView) { WebSettings webSettings = webView.getSettings(); webSettings.setAppCacheEnabled(false); webSettings.setJavaScriptEnabled(true); webView.setWebViewClient(new WebViewClient()); }
From source file:jlelse.simplewebwrapper.SimpleWebWrapperActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // FAB// w w w . ja va 2 s. co m enableFabChanges(); //WebView webView = new WebView(this); WebSettings webSettings = webView.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setAppCacheEnabled(true); webView.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { if (isOnlyOwnPagesAllowed()) { if (Uri.parse(url).getHost().equals(Uri.parse(getStartUrl()).getHost())) { loadUrl(url); return false; } Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); startActivity(intent); return true; } else { return false; } } @Override public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) { handler.proceed(); } }); addContentView(webView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); }
From source file:net.olejon.mdapp.MedicationNlhFragment.java
@SuppressLint("SetJavaScriptEnabled") @Override//from ww w.j ava2s . com public View onCreateView(LayoutInflater inflater, ViewGroup container, final Bundle savedInstanceState) { ViewGroup viewGroup = (ViewGroup) inflater.inflate(R.layout.fragment_medication_nlh, container, false); // Activity final Activity activity = getActivity(); // Context final Context context = activity.getApplicationContext(); // Tools final MyTools mTools = new MyTools(context); // Arguments Bundle bundle = getArguments(); final String pageUri = bundle.getString("uri"); // Progress bar final ProgressBar progressBar = (ProgressBar) activity .findViewById(R.id.medication_toolbar_progressbar_horizontal); // Toolbar final LinearLayout toolbarSearchLayout = (LinearLayout) activity .findViewById(R.id.medication_toolbar_search_layout); final EditText toolbarSearchEditText = (EditText) activity.findViewById(R.id.medication_toolbar_search); // Web view WEBVIEW = (WebView) viewGroup.findViewById(R.id.medication_nlh_content); WebSettings webSettings = WEBVIEW.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setAppCacheEnabled(true); webSettings.setDomStorageEnabled(true); webSettings.setAppCachePath(context.getCacheDir().getAbsolutePath()); webSettings.setCacheMode(WebSettings.LOAD_DEFAULT); WEBVIEW.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { if (!mTools.isDeviceConnected()) { mTools.showToast(getString(R.string.device_not_connected), 0); return true; } else if (url.matches(".*/[^#]+#[^/]+$")) { WEBVIEW.loadUrl(url.replaceAll("#[^/]+$", "")); return true; } else if (url.matches("^https?://.*?\\.pdf$")) { mTools.downloadFile(view.getTitle(), url); return true; } return false; } }); WEBVIEW.setWebChromeClient(new WebChromeClient() { @Override public void onProgressChanged(WebView view, int newProgress) { if (newProgress == 100) { progressBar.setVisibility(View.INVISIBLE); } else { progressBar.setVisibility(View.VISIBLE); progressBar.setProgress(newProgress); toolbarSearchLayout.setVisibility(View.GONE); toolbarSearchEditText.setText(""); } } }); if (savedInstanceState == null) { WEBVIEW.loadUrl(pageUri); } else { WEBVIEW.restoreState(savedInstanceState); } return viewGroup; }
From source file:de.trier.infsec.koch.droidsheep.activities.HijackActivity.java
private void setupWebView() { webview = (WebView) findViewById(R.id.webviewhijack); webview.setWebViewClient(new MyWebViewClient()); WebSettings webSettings = webview.getSettings(); webSettings.setUserAgentString("foo"); webSettings.setJavaScriptEnabled(true); webSettings.setAppCacheEnabled(false); webSettings.setBuiltInZoomControls(true); webview.setWebChromeClient(new WebChromeClient() { public void onProgressChanged(WebView view, int progress) { HijackActivity.this.setProgress(progress * 100); }/* ww w . j a va 2 s . com*/ }); }
From source file:org.noise_planet.noisecapture.MapFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (view == null) { // Inflate the layout for this fragment view = inflater.inflate(R.layout.fragment_measurement_map, container, false); leaflet = (WebView) view.findViewById(R.id.measurement_webmapview); leaflet.clearCache(true);/* w w w . ja v a 2 s . c o m*/ leaflet.clearHistory(); WebSettings webSettings = leaflet.getSettings(); webSettings.setJavaScriptEnabled(true); WebSettings settings = leaflet.getSettings(); settings.setAppCachePath(new File(getContext().getCacheDir(), "webview").getPath()); settings.setAppCacheEnabled(true); leaflet.setWebViewClient(new WebViewClient() { @Override public void onPageFinished(WebView view, String url) { super.onPageFinished(view, url); pageLoaded.set(true); if (mapFragmentAvailableListener != null) { mapFragmentAvailableListener.onPageLoaded(MapFragment.this); } } @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); startActivity(browserIntent); return true; } }); if (mapFragmentAvailableListener != null) { mapFragmentAvailableListener.onMapFragmentAvailable(this); } } return view; }
From source file:com.clutch.ClutchView.java
@SuppressLint("SetJavaScriptEnabled") private void clutchInit() { loading = new ProgressDialog(this.getContext()); loading.hide();/*from w ww . j ava 2s. c om*/ this.setWebChromeClient(new WebChromeClient() { // TODO: Clutch Debug Toolbar @Override public boolean onJsPrompt(WebView view, String url, String message, String defaultValue, JsPromptResult result) { if (!"methodCalled".equals(defaultValue)) { return false; } JSONObject jsonMessage = null; String methodName = null; String callbackId = null; JSONObject params = null; try { jsonMessage = new JSONObject(message); methodName = jsonMessage.getString("method"); callbackId = jsonMessage.getString("callbackNum"); params = jsonMessage.getJSONObject("args"); } catch (JSONException e) { Log.e(TAG, "Could not decode JSON: " + message); result.cancel(); return true; } if (methodName.equals("clutch.loading.begin")) { String loadingMessage = params.optString("text"); if (loadingMessage == null) { loadingMessage = "Loading..."; } else if ("null".equals(loadingMessage)) { loadingMessage = "Loading..."; } loading.setMessage(loadingMessage); loading.show(); } else if (methodName.equals("clutch.loading.end")) { loading.hide(); } ClutchCallback callback = null; if (!"0".equals(callbackId)) { callback = new ClutchCallback(ClutchView.this, callbackId); } dispatcher.methodCalled(methodName, params, callback); result.cancel(); return true; } }); ClutchSync.addClutchView(this); WebSettings settings = this.getSettings(); settings.setJavaScriptEnabled(true); settings.setSupportZoom(true); settings.setAppCacheEnabled(false); }
From source file:com.tdispatch.passenger.fragment.OAuthFragment.java
@SuppressLint("SetJavaScriptEnabled") @Override/*from ww w . ja v a 2 s .c om*/ protected void onPostCreateView() { View v = mFragmentView.findViewById(R.id.button_cancel); v.setOnClickListener(mOnClickListener); ProgressBar pb = (ProgressBar) mFragmentView.findViewById(R.id.progressbar); pb.setVisibility(View.GONE); mWebView = (WebView) mFragmentView.findViewById(R.id.webview); if (mWebView != null) { mWebView.setWebViewClient(new MyWebViewClient()); mWebView.setWebChromeClient(new MyWebchromeClient()); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { mWebView.setOnTouchListener(mOnTouchListener); } WebSettings webSettings = mWebView.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE); webSettings.setAppCacheEnabled(false); webSettings.setSavePassword(false); webSettings.setSaveFormData(false); CookieSyncManager.createInstance(mContext); CookieManager cm = CookieManager.getInstance(); cm.setAcceptCookie(true); cm.removeAllCookie(); try { ApiRequest req = new ApiRequest(Const.Api.OauthAuthUrl); req.addGetParam("key", Const.getApiKey()); req.addGetParam("scope", ""); req.addGetParam("response_type", "code"); req.addGetParam("client_id", Const.getOAuthClientId()); req.addGetParam("redirect_uri", mOAuthRedirectUrl); req.buildRequest(); String url = req.getUrl(); mWebView.loadUrl(url); } catch (Exception e) { WebnetLog.e("Failed to load oauth launch page..."); } } else { WebnetLog.e("Failed to init WebView. Aborting"); mHostActivity.oAuthCancelled(); } }
From source file:com.zbrown.droidsteal.activities.HijackActivity.java
private void setupWebView() { webview = (WebView) findViewById(R.id.webviewhijack); webview.setWebViewClient(new MyWebViewClient()); WebSettings webSettings = webview.getSettings(); webSettings.setUserAgentString(//from w ww. ja v a 2 s . c o m "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1667.0 Safari/537.36"); webSettings.setJavaScriptEnabled(true); //Blah blah JavaScript is scary blah blah webSettings.setAppCacheEnabled(false); webSettings.setBuiltInZoomControls(true); webSettings.setDisplayZoomControls(false); webview.setWebChromeClient(new WebChromeClient() { @Override public void onProgressChanged(WebView view, int progress) { HijackActivity.this.setProgress(progress * 100); int fprogress = (Window.PROGRESS_END) / 100 * progress; setProgress(fprogress); if (progress == 100) { setProgressBarIndeterminateVisibility(false); } } }); }
From source file:com.rfo.basic.Web.java
@Override protected void onCreate(Bundle savedInstanceState) { Log.v(LOGTAG, "onCreate"); super.onCreate(savedInstanceState); ContextManager cm = Basic.getContextManager(); cm.registerContext(ContextManager.ACTIVITY_WEB, this); cm.setCurrent(ContextManager.ACTIVITY_WEB); setContentView(R.layout.web);//from www . j a v a 2s . c o m View v = findViewById(R.id.web_engine); Intent intent = getIntent(); int showStatusBar = intent.getIntExtra(EXTRA_SHOW_STATUSBAR, 0); int orientation = intent.getIntExtra(EXTRA_ORIENTATION, -1); showStatusBar = (showStatusBar == 0) ? WindowManager.LayoutParams.FLAG_FULLSCREEN // do not show status bar : WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN; // show status bar getWindow().setFlags(showStatusBar, showStatusBar); setOrientation(orientation); engine = (WebView) v; WebSettings webSettings = engine.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setBuiltInZoomControls(true); webSettings.setSupportZoom(true); webSettings.setAppCacheEnabled(true); webSettings.setDatabaseEnabled(true); webSettings.setDomStorageEnabled(true); webSettings.setAllowFileAccess(true); webSettings.setGeolocationEnabled(true); webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE); engine.addJavascriptInterface(new JavaScriptInterface(), "Android"); engine.setWebViewClient(new MyWebViewClient()); aWebView = new TheWebView(this); engine.setWebChromeClient(new WebChromeClient() { @Override public boolean onJsAlert(WebView view, String url, String message, JsResult result) { //Required functionality here return super.onJsAlert(view, url, message, result); } }); }