List of usage examples for android.webkit WebSettings LOAD_NO_CACHE
int LOAD_NO_CACHE
To view the source code for android.webkit WebSettings LOAD_NO_CACHE.
Click Source Link
From source file:com.akingyin.librarys.widgets.BrowserLayout.java
private void init(Context context) { mContext = context;//from ww w.j a v a2 s.c o m setOrientation(VERTICAL); mProgressBar = (ProgressBar) LayoutInflater.from(context).inflate(R.layout.progress_horizontal, null); mProgressBar.setMax(100); mProgressBar.setProgress(0); addView(mProgressBar, LayoutParams.MATCH_PARENT, (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PX, mBarHeight, getResources().getDisplayMetrics())); mWebView = new WebView(context); mWebView.getSettings().setJavaScriptEnabled(true); mWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); mWebView.getSettings().setDefaultTextEncodingName("UTF-8"); mWebView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE); mWebView.getSettings().setBuiltInZoomControls(false); mWebView.getSettings().setSupportMultipleWindows(true); mWebView.getSettings().setUseWideViewPort(true); mWebView.getSettings().setLoadWithOverviewMode(true); mWebView.getSettings().setSupportZoom(false); mWebView.getSettings().setPluginState(WebSettings.PluginState.ON); mWebView.getSettings().setDomStorageEnabled(true); mWebView.getSettings().setLoadsImagesAutomatically(true); LayoutParams lps = new LayoutParams(LayoutParams.MATCH_PARENT, 0, 1); addView(mWebView, lps); mWebView.setWebChromeClient(new WebChromeClient() { @Override public void onProgressChanged(WebView view, int newProgress) { super.onProgressChanged(view, newProgress); if (newProgress == 100) { mProgressBar.setVisibility(View.GONE); } else { mProgressBar.setVisibility(View.VISIBLE); mProgressBar.setProgress(newProgress); } } }); mWebView.setWebViewClient(new WebViewClient() { public void onPageFinished(WebView view, String url) { super.onPageFinished(view, url); mLoadUrl = url; } }); mBrowserControllerView = LayoutInflater.from(context).inflate(R.layout.browser_controller, null); mGoBackBtn = (ImageButton) mBrowserControllerView.findViewById(R.id.browser_controller_back); mGoForwardBtn = (ImageButton) mBrowserControllerView.findViewById(R.id.browser_controller_forward); mGoBrowserBtn = (ImageButton) mBrowserControllerView.findViewById(R.id.browser_controller_go); mRefreshBtn = (ImageButton) mBrowserControllerView.findViewById(R.id.browser_controller_refresh); mGoBackBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (canGoBack()) { goBack(); } } }); mGoForwardBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (canGoForward()) { goForward(); } } }); mRefreshBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { loadUrl(mLoadUrl); } }); mGoBrowserBtn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (!TextUtils.isEmpty(mLoadUrl)) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(mLoadUrl)); mContext.startActivity(intent); } } }); addView(mBrowserControllerView, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); }
From source file:net.nym.mutils.ui.test.TestWebViewActivity.java
private void initWebView() { mWebView.canGoBackOrForward(10);//w w w . j a v a2 s . c o m mWebView.getSettings().setJavaScriptEnabled(true); mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { mWebView.getSettings().setAllowContentAccess(true); } mWebView.getSettings().setAllowFileAccess(true); mWebView.getSettings().setPluginState(WebSettings.PluginState.ON); mWebView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE); /** * Sets whether the WebView loads pages in overview mode, that is, * zooms out the content to fit on screen by width. This setting is * taken into account when the content width is greater than the width * of the WebView control, for example, when {@link #getUseWideViewPort} * is enabled. The default is false. */ mWebView.getSettings().setUseWideViewPort(true); mWebView.getSettings().setLoadWithOverviewMode(true); //?? mWebView.getSettings().setDatabaseEnabled(true); String dir = this.getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath(); //? mWebView.getSettings().setDatabasePath(dir); //??? // <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> // <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> mWebView.getSettings().setGeolocationEnabled(true); //(?) //?? mWebView.getSettings().setGeolocationDatabasePath(dir); //(?) mWebView.getSettings().setDomStorageEnabled(true); //?Dom // mWebView.getSettings().setRenderPriority(RenderPriority.HIGH); // mWebView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT); // mWebView.setLayerType(View.LAYER_TYPE_SOFTWARE, null); mWebView.setWebChromeClient( new MWebChromeClient(new MWebChromeClient.UploadFileInvoke(this, FILE_CHOOSER_RESULT_CODE) { @Override public void onCallBack(ValueCallback<Uri> uploadFile) { mUploadMessage = uploadFile; } })); mWebView.setWebViewClient(new MWebViewClient()); mWebView.addJavascriptInterface(new JSCall(this), "Game"); loadUrl(); }
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. ja v a 2 s . com websettings.setSavePassword(false); websettings.setSupportMultipleWindows(false); websettings.setAppCacheEnabled(false); websettings.setCacheMode(WebSettings.LOAD_NO_CACHE); websettings.setBlockNetworkImage(true); return view; }
From source file:com.centurylink.mdw.mobile.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);/*from w w w. j a va 2 s . c o m*/ DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.setDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); settings = new Settings(getApplicationContext()); webView = (WebView) findViewById(R.id.webview); webView.setWebViewClient(new WebViewClient() { public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } }); webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setAllowUniversalAccessFromFileURLs(true); webView.getSettings().setUseWideViewPort(true); webView.getSettings().setSupportZoom(true); // webView.getSettings().setBuiltInZoomControls(true); // allow debugging with chrome dev tools WebView.setWebContentsDebuggingEnabled(true); // do not cache in debug webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE); webView.getSettings().setAppCacheEnabled(false); webView.clearCache(true); }
From source file:com.scm.reader.resultPage.ui.ItemViewFragment.java
protected void initializeWebView(WebView webView) { // webview settings webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setUserAgentString(getSDKUserAgentString()); webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE); webView.getSettings().setDomStorageEnabled(true); webView.getSettings().setAllowFileAccess(true); mWebView.addJavascriptInterface(new ItemViewJavascriptInterface(getActivity(), mWebViewClient), "Android"); }
From source file:no.digipost.android.gui.metadata.ExternalLinkWebview.java
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); ((DigipostApplication) getApplication()).getTracker(DigipostApplication.TrackerName.APP_TRACKER); setContentView(R.layout.activity_externallink_webview); Bundle bundle = getIntent().getExtras(); fileUrl = bundle.getString("url", "https://www.digipost.no"); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);//from w ww . java2 s.c om actionBar = getSupportActionBar(); if (actionBar != null) { setActionBarTitle(fileUrl); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setBackgroundDrawable(new ColorDrawable(0xff2E2E2E)); if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Window window = this.getWindow(); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor( ContextCompat.getColor(this, R.color.metadata_externalbrowser_top_background)); } } progressSpinner = (ProgressBar) findViewById(R.id.externallink_spinner); webView = (WebView) findViewById(R.id.externallink_webview); WebSettings settings = webView.getSettings(); settings.setJavaScriptEnabled(true); settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN); settings.setDomStorageEnabled(true); settings.setLoadWithOverviewMode(true); settings.setUseWideViewPort(true); settings.setSupportZoom(true); settings.setBuiltInZoomControls(true); settings.setDisplayZoomControls(false); settings.setCacheMode(WebSettings.LOAD_NO_CACHE); webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY); webView.setScrollbarFadingEnabled(true); enableCookies(webView); webView.setWebViewClient(new WebViewClient() { @Override public void onPageFinished(WebView view, String url) { super.onPageFinished(view, url); if (firstLoad) { progressSpinner.setVisibility(View.GONE); webView.setVisibility(View.VISIBLE); firstLoad = false; } setActionBarTitle(view.getUrl()); } }); webView.setDownloadListener(new DownloadListener() { @Override public void onDownloadStart(final String url, final String userAgent, final String content, final String mimeType, final long contentLength) { fileName = URLUtil.guessFileName(url, content, mimeType); fileUrl = url; onComplete = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(action)) { showDownloadSuccessDialog(context); } } }; registerReceiver(onComplete, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)); if (!mimeType.equals("text/html")) { if (FileUtilities.isStorageWriteAllowed(getApplicationContext())) { showDownloadDialog(userAgent, content, mimeType, contentLength); } else { showMissingPermissionsDialog(); } } } }); if (FileUtilities.isStorageWriteAllowed(this)) { webView.loadUrl(fileUrl); } else { showPermissionsDialog(); } }
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 w w w . j ava 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); } }); }
From source file:com.tdispatch.passenger.fragment.OAuthFragment.java
@SuppressLint("SetJavaScriptEnabled") @Override/* w w w . j a v a2s . com*/ 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:mobisocial.musubi.webapp.WebAppActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.appcorral);//from w w w . j a v a 2 s .c o m mMusubi = App.getMusubi(this); getSupportActionBar().hide(); mAppId = getIntent().getStringExtra(EXTRA_APP_ID); if (mAppId == null) { toast("Must set app id for socialKitJS binding."); finish(); return; } mArgumentName = getIntent().getStringExtra(EXTRA_APP_NAME); if (mArgumentName == null) { mArgumentName = "Application"; } mObjUri = getIntent().getData(); if (mObjUri != null) { mArgumentData = mMusubi.objForUri(mObjUri); } mFeedUri = (Uri) getIntent().getParcelableExtra(Musubi.EXTRA_FEED_URI); if (mFeedUri != null) { mArgumentFeed = mMusubi.getFeed(mFeedUri); } if (savedInstanceState != null) { mCurrentPage = savedInstanceState.getString(EXTRA_CURRENT_PAGE); } else { Uri appUrl = getIntent().getParcelableExtra(EXTRA_APP_URI); if (appUrl != null) { mCurrentPage = appUrl.toString(); } } if (mCurrentPage == null) { Log.w(TAG, "No WebApp specified, bailing."); finish(); return; } mWebView = (WebView) findViewById(R.id.webview); mWebView.getSettings().setJavaScriptEnabled(true); mWebView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE); WebAppWebViewClient webapp = new WebAppWebViewClient(this, mWebView, mAppId); mWebView.setWebViewClient(webapp); mWebView.addJavascriptInterface(webapp.mSocialKitJavascript, SocialKitJavascript.MUSUBI_JS_VAR); mWebView.setWebChromeClient(new WebAppWebChromeClient(webapp)); new DataFromLocalhostTask(webapp).execute(); }
From source file:au.com.wallaceit.reddinator.TabCommentsFragment.java
@SuppressLint({ "SetJavaScriptEnabled", "AddJavascriptInterface" }) public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mContext = this.getActivity(); SharedPreferences mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(mContext); global = (GlobalObjects) mContext.getApplicationContext(); final boolean load = getArguments().getBoolean("load"); // get needed activity values articleId = getActivity().getIntent().getStringExtra(WidgetProvider.ITEM_ID); permalink = getActivity().getIntent().getStringExtra(WidgetProvider.ITEM_PERMALINK); ll = new LinearLayout(mContext); ll.setLayoutParams(new WebView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 0, 0)); // fixes for webview not taking keyboard input on some devices mWebView = new WebView(mContext); mWebView.setLayoutParams(new WebView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 0, 0)); ll.addView(mWebView);// ww w . j a v a 2s . c o m WebSettings webSettings = mWebView.getSettings(); webSettings.setJavaScriptEnabled(true); // enable ecmascript webSettings.setDomStorageEnabled(true); // some video sites require dom storage webSettings.setSupportZoom(false); webSettings.setBuiltInZoomControls(false); webSettings.setDisplayZoomControls(false); int fontSize = Integer.parseInt(mSharedPreferences.getString("commentfontpref", "18")); webSettings.setDefaultFontSize(fontSize); webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE); mSharedPreferences.getString("titlefontpref", "16"); final String themeStr = global.mThemeManager.getActiveTheme("appthemepref").getValuesString(); mWebView.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { boolean redditLink = false; System.out.println(url); if (url.indexOf("file://") == 0) { // fix for short sub and user links url = url.replace("file://", "https://www.reddit.com") + "/.compact"; redditLink = true; } if (redditLink || url.indexOf("https://www.reddit.com/") == 0) { Intent i = new Intent(mContext, WebViewActivity.class); i.putExtra("url", url); startActivity(i); } else { Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); startActivity(i); } return true; // always override url } public void onPageFinished(WebView view, String url) { mWebView.loadUrl("javascript:init(\"" + StringEscapeUtils.escapeJavaScript(themeStr) + "\", \"" + global.mRedditData.getUsername() + "\")"); if (load) load(); } }); mWebView.setWebChromeClient(new WebChromeClient()); mWebView.requestFocus(View.FOCUS_DOWN); WebInterface webInterface = new WebInterface(mContext); mWebView.addJavascriptInterface(webInterface, "Reddinator"); mWebView.loadUrl("file:///android_asset/comments.html#" + articleId); }