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.anxpp.blog.fragment.AboutFragment.java
@SuppressLint("SetJavaScriptEnabled") private void initView() { webView = (WebView) getView().findViewById(R.id.webView); // webView.setVisibility(View.GONE); webView.setWebChromeClient(new WebChromeClient() { public void onProgressChanged(WebView view, int progress) { Activity activity = getActivity(); /**//from www.java 2 s . c o m * ?Fragment??? * I am not sure why are you getting this error, * i think it should be something like NullPointerException. * Try next: * Evert time you calling getActivity() on Fragment instance you should be sure, * that fragment is actually have this Activity. * Because when your webview is loading you are calling this function: * */ if (activity == null) return; activity.setTitle("Loading..." + progress + "%"); activity.setProgress(progress * 100); if (progress == 100) { activity.setTitle(R.string.app_name); webView.setVisibility(View.VISIBLE); } } }); webView.setWebViewClient(new WebViewClient() { public boolean shouldOverrideUrlLoading(WebView view, String url) { Toast("shouldOverrideUrlLoading"); view.loadUrl(url); return true; } }); //?? WebSettings webSettings = webView.getSettings(); //? //webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE); //?js webSettings.setJavaScriptEnabled(true); //? ? webSettings.setUseWideViewPort(false); //?? webSettings.setLoadWithOverviewMode(true); // ?? webView.loadUrl("http://anxpp.com"); // webView.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { //trueWebViewfalse?? view.loadUrl(url); return true; //false? } }); webView.setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN) { if (keyCode == KeyEvent.KEYCODE_BACK && webView.canGoBack()) { // ? webView.goBack(); //? return true; //? } } return false; } }); }
From source file:de.geeksfactory.opacclient.frontend.InfoFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == R.id.action_refresh) { wvInfo.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE); load();/* w w w . ja v a 2 s. c om*/ return true; } return super.onOptionsItemSelected(item); }
From source file:com.example.nq.journalism_master.innerbrowser.InnerBrowserFragment.java
private void initWebViewSettings(WebView webView) { //js/*from w w w. j a v a 2 s. c o m*/ webView.getSettings().setJavaScriptEnabled(true); //,???? webView.getSettings().setBuiltInZoomControls(false); // webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE); //?DOM storage API webView.getSettings().setDomStorageEnabled(true); //?application Cache webView.getSettings().setAppCacheEnabled(false); }
From source file:org.catnut.fragment.OAuthFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // clear cache WebSettings settings = mWebView.getSettings(); settings.setJavaScriptEnabled(true); settings.setCacheMode(WebSettings.LOAD_NO_CACHE); settings.setSaveFormData(false);//w w w . ja v a 2 s .com mWebView.loadUrl(Manifest.getOAuthUri()); }
From source file:com.wpi.assistments.HomeTabbedActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.activity_webview); final ProgressDialog pd = ProgressDialog.show(this, "", "Loading...", true); isTeacher = false;/* ww w.ja v a2s . c o m*/ toggle = true; logoutFlag = false; homeWebView = (WebView) findViewById(R.id.homeWebView); homeWebView.setWebViewClient(new WebViewClient() { public void onPageFinished(WebView view, String url) { Log.i("test", view.getUrl()); if (view.getUrl().equals("https://www.assistments.org/account/login") && !logoutFlag) { Intent intent = new Intent(getApplicationContext(), LoginActivity.class); intent.putExtra("showPopup", "true"); startActivity(intent); finish(); } else if (view.getUrl().equals("https://www.assistments.org/teacher")) { isTeacher = true; } else if (view.getUrl().equals("https://www.assistments.org/account/login") && logoutFlag) { Intent intent = new Intent(getApplicationContext(), LoginActivity.class); startActivity(intent); } if (!homeWebView.canGoBack()) { btnBack.setEnabled(false); } else { btnBack.setEnabled(true); } if (!homeWebView.canGoForward()) { btnForward.setEnabled(false); } else { btnForward.setEnabled(true); } if (pd.isShowing() && pd != null) { pd.dismiss(); } } @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { pd.show(); view.loadUrl(url); return true; } }); homeWebView.setWebChromeClient(new WebChromeClient() { @Override public boolean onJsConfirm(WebView view, String url, String message, final JsResult result) { new AlertDialog.Builder(webviewContext).setTitle("ASSISTments").setMessage(message) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { logoutFlag = true; result.confirm(); } }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { result.cancel(); } }).create().show(); return true; } }); if (savedInstanceState != null) { homeWebView.restoreState(savedInstanceState); } else { /** Scaling, replaced by overview mode and wide view port Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); if (size.x <= 780) { int scaleRate = (int) ((size.x) / 7.8); Log.i("test", Integer.toString(size.x)); homeWebView.setInitialScale(scaleRate); } */ Intent intent = getIntent(); if (intent.getStringExtra("username").equals("") && intent.getStringExtra("password").equals("")) { homeWebView.loadUrl("https://www.assistments.org/signup"); } else { String username = intent.getStringExtra("username"); String password = intent.getStringExtra("password"); String postData = "login=" + username + "&password=" + password + "&commit=Log in"; homeWebView.postUrl("https://www.assistments.org/account/login", EncodingUtils.getBytes(postData, "BASE64")); } } WebSettings settings = homeWebView.getSettings(); settings.setSaveFormData(false); settings.setSavePassword(false); settings.setJavaScriptEnabled(true); settings.setBuiltInZoomControls(true); settings.setDisplayZoomControls(false); settings.setJavaScriptCanOpenWindowsAutomatically(true); settings.setSupportMultipleWindows(true); settings.setCacheMode(WebSettings.LOAD_NO_CACHE); settings.setAppCacheEnabled(false); settings.setDomStorageEnabled(true); settings.setDatabaseEnabled(true); settings.setUseWideViewPort(false); settings.setLoadWithOverviewMode(true); homeWebView.clearCache(true); homeWebView.setPadding(0, 0, 0, 0); homeWebView.setInitialScale(getScale()); btnBack = (Button) findViewById(R.id.btnBack); btnBack.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { homeWebView.goBack(); } }); btnRefresh = (Button) findViewById(R.id.btnRefresh); btnRefresh.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //homeWebView.zoomOut(); homeWebView.scrollTo(1000, 0); Log.i("test", "111"); //homeWebView.reload(); } }); btnForward = (Button) findViewById(R.id.btnForward); btnForward.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { homeWebView.goForward(); } }); btnOffline = (Button) findViewById(R.id.btnOffline); btnOffline.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (toggle) { homeWebView.loadUrl( "https://www.assistments.org/assistments/student/index.html#offlineUserAssignmentList/"); btnOffline.setText("Home"); toggle = false; } else { if (isTeacher) { homeWebView.loadUrl("https://www.assistments.org/teacher"); } else { homeWebView.loadUrl("https://www.assistments.org/tutor"); } btnOffline.setText("Offline"); toggle = true; } } }); }
From source file:com.svo.library.widget.RLWebBrowser.java
private void init(Context context) { this.context = context; View rootView = LayoutInflater.from(context).inflate(R.layout.web_browser, null); this.addView(rootView); layout_loading = (LinearLayout) rootView.findViewById(R.id.layout_loading); layout_loading.setVisibility(View.GONE); iv_refresh = (ImageView) rootView.findViewById(R.id.iv_refresh); iv_refresh.setOnClickListener(myClickListener); iv_stop = (ImageView) rootView.findViewById(R.id.iv_stop); iv_stop.setOnClickListener(myClickListener); iv_goback = (ImageView) rootView.findViewById(R.id.iv_goback); iv_goback.setOnClickListener(myClickListener); iv_more = (ImageView) rootView.findViewById(R.id.iv_more); iv_more.setOnClickListener(myClickListener); iv_goback.setEnabled(false);/* w w w . j av a 2 s. c o m*/ iv_goforward = (ImageView) rootView.findViewById(R.id.iv_goforward); iv_goforward.setOnClickListener(myClickListener); iv_goforward.setEnabled(false); webView = (WebView) rootView.findViewById(R.id.webView); webView.getSettings().setSupportZoom(true); webView.getSettings().setSaveFormData(false); webView.getSettings().setSavePassword(false); webView.getSettings().setPluginState(PluginState.ON); webView.getSettings().setUseWideViewPort(true); webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setBlockNetworkLoads(false); webView.getSettings().setLoadWithOverviewMode(true); webView.getSettings().setRenderPriority(RenderPriority.HIGH); webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE); webView.setWebChromeClient(myWebChromeClient); webView.setWebViewClient(myWebViewClient); webView.setOnTouchListener(myTouchListener); webView.setDownloadListener(myDownLoadListener); webView.removeJavascriptInterface("searchBoxJavaBredge_"); }
From source file:com.almarsoft.GroundhogReader.MessageActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mContext = getApplicationContext();// w w w . j a v a2s. com setContentView(R.layout.message); // Config checker alert dialog mConfigAlert = new AlertDialog.Builder(this).create(); mConfigAlert.setButton(getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dlg, int sumthin) { startActivity(new Intent(MessageActivity.this, OptionsActivity.class)); } }); mPrefs = PreferenceManager.getDefaultSharedPreferences(this); mOfflineMode = mPrefs.getBoolean("offlineMode", true); Bundle extras = getIntent().getExtras(); mMsgIndexInArray = extras.getInt("msgIndexInArray"); mArticleNumbersArray = extras.getLongArray("articleNumbers"); mGroup = extras.getString("group"); mMainLayout = (LinearLayout) this.findViewById(R.id.main_message_layout); //mLayoutAuthor = (LinearLayout) this.findViewById(R.id.layout_author); mLayoutSubject = (LinearLayout) this.findViewById(R.id.layout_subject); mLayoutDate = (LinearLayout) this.findViewById(R.id.layout_date); mAuthor = (TextView) this.findViewById(R.id.text_author); mHeart = (ImageView) this.findViewById(R.id.img_love); //mHeart.setVisibility(ImageView.INVISIBLE); mDate = (TextView) this.findViewById(R.id.text_date); mSubject = (TextView) this.findViewById(R.id.text_subject); mSubjectText = null; mLastSubject = null; mContent = (WebView) this.findViewById(R.id.text_content); mWebSettings = mContent.getSettings(); mWebSettings.setDefaultTextEncodingName("utf-8"); mWebSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN); mWebSettings.setCacheMode(WebSettings.LOAD_NO_CACHE); mWebSettings.setJavaScriptEnabled(false); mWebSettings.setRenderPriority(WebSettings.RenderPriority.HIGH); mWebSettings.setSupportZoom(false); this.setWebViewSizeFromPrefs(0); mScroll = (ScrollView) this.findViewById(R.id.textAreaScroller); // Conectar los botones next y prev (sumar/restar 1 a mMsgIndexInArray y // llamar a loadMessage(); mButton_Prev = (ImageButton) this.findViewById(R.id.btn_prev); mButton_Prev.setOnClickListener(new OnClickListener() { public void onClick(View arg0) { if (mMsgIndexInArray > 0) { mMsgIndexInArray--; loadMessage(); } else { Toast.makeText(MessageActivity.this, getString(R.string.at_first_message), Toast.LENGTH_SHORT) .show(); } } }); mButton_Next = (ImageButton) this.findViewById(R.id.btn_next); mButton_Next.setOnClickListener(new OnClickListener() { public void onClick(View arg0) { if (mMsgIndexInArray + 1 < mArticleNumbersArray.length) { mMsgIndexInArray++; loadMessage(); } else { Toast.makeText(MessageActivity.this, getString(R.string.no_more_messages), Toast.LENGTH_SHORT) .show(); } } }); mButton_GoGroup = (ImageButton) this.findViewById(R.id.btn_gogroup); mButton_GoGroup.setOnClickListener(new OnClickListener() { public void onClick(View v) { /* Intent intent_MsgList = new Intent(MessageActivity.this, MessageListActivity.class); intent_MsgList.putExtra("selectedGroup", mGroup); MessageActivity.this.startActivity(intent_MsgList); */ MessageActivity.this.finish(); } }); mServerManager = new ServerManager(mContext); loadMessage(); mButton_Prev.setFocusable(false); mButton_Next.setFocusable(false); mContent.requestFocus(); }
From source file:de.mkrtchyan.recoverytools.SettingsFragment.java
public static void showChangelog(Context AppContext) { AlertDialog.Builder dialog = new AlertDialog.Builder(AppContext); dialog.setTitle(R.string.changelog); WebView changes = new WebView(AppContext); changes.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE); changes.setWebViewClient(new WebViewClient()); changes.loadUrl(Constants.CHANGELOG_URL); changes.clearCache(true);// w w w.ja v a 2 s . c om dialog.setView(changes); dialog.show(); }
From source file:org.odk.collect.android.widgets.ImageWebViewWidget.java
public ImageWebViewWidget(Context context, FormEntryPrompt prompt) { super(context, prompt); mInstanceFolder = Collect.getInstance().getFormController().getInstancePath().getParent(); TableLayout.LayoutParams params = new TableLayout.LayoutParams(); params.setMargins(7, 5, 7, 5);//from w w w.j a v a 2 s . c o m mErrorTextView = new TextView(context); mErrorTextView.setId(QuestionWidget.newUniqueId()); mErrorTextView.setText("Selected file is not a valid image"); // setup capture button mCaptureButton = new Button(getContext()); mCaptureButton.setId(QuestionWidget.newUniqueId()); mCaptureButton.setText(getContext().getString(R.string.capture_image)); mCaptureButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mAnswerFontsize); mCaptureButton.setPadding(20, 20, 20, 20); mCaptureButton.setEnabled(!prompt.isReadOnly()); mCaptureButton.setLayoutParams(params); // launch capture intent on click mCaptureButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Collect.getInstance().getActivityLogger().logInstanceAction(this, "captureButton", "click", mPrompt.getIndex()); mErrorTextView.setVisibility(View.GONE); Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); // We give the camera an absolute filename/path where to put the // picture because of bug: // http://code.google.com/p/android/issues/detail?id=1480 // The bug appears to be fixed in Android 2.0+, but as of feb 2, // 2010, G1 phones only run 1.6. Without specifying the path the // images returned by the camera in 1.6 (and earlier) are ~1/4 // the size. boo. // if this gets modified, the onActivityResult in // FormEntyActivity will also need to be updated. Uri tempPath = FileProvider.getUriForFile(getContext(), BuildConfig.APPLICATION_ID + ".provider", new File(Collect.TMPFILE_PATH)); i.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, tempPath); try { Collect.getInstance().getFormController().setIndexWaitingForData(mPrompt.getIndex()); ((Activity) getContext()).startActivityForResult(i, FormEntryActivity.IMAGE_CAPTURE); } catch (ActivityNotFoundException e) { Toast.makeText(getContext(), getContext().getString(R.string.activity_not_found, "image capture"), Toast.LENGTH_SHORT).show(); Collect.getInstance().getFormController().setIndexWaitingForData(null); } } }); // setup chooser button mChooseButton = new Button(getContext()); mChooseButton.setId(QuestionWidget.newUniqueId()); mChooseButton.setText(getContext().getString(R.string.choose_image)); mChooseButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mAnswerFontsize); mChooseButton.setPadding(20, 20, 20, 20); mChooseButton.setEnabled(!prompt.isReadOnly()); mChooseButton.setLayoutParams(params); // launch capture intent on click mChooseButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Collect.getInstance().getActivityLogger().logInstanceAction(this, "chooseButton", "click", mPrompt.getIndex()); mErrorTextView.setVisibility(View.GONE); Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.setType("image/*"); try { Collect.getInstance().getFormController().setIndexWaitingForData(mPrompt.getIndex()); ((Activity) getContext()).startActivityForResult(i, FormEntryActivity.IMAGE_CHOOSER); } catch (ActivityNotFoundException e) { Toast.makeText(getContext(), getContext().getString(R.string.activity_not_found, "choose image"), Toast.LENGTH_SHORT) .show(); Collect.getInstance().getFormController().setIndexWaitingForData(null); } } }); // finish complex layout LinearLayout answerLayout = new LinearLayout(getContext()); answerLayout.setOrientation(LinearLayout.VERTICAL); answerLayout.addView(mCaptureButton); answerLayout.addView(mChooseButton); answerLayout.addView(mErrorTextView); // and hide the capture and choose button if read-only if (prompt.isReadOnly()) { mCaptureButton.setVisibility(View.GONE); mChooseButton.setVisibility(View.GONE); } mErrorTextView.setVisibility(View.GONE); // retrieve answer from data model and update ui mBinaryName = prompt.getAnswerText(); // Only add the imageView if the user has taken a picture if (mBinaryName != null) { mImageDisplay = new WebView(getContext()); mImageDisplay.setId(QuestionWidget.newUniqueId()); mImageDisplay.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE); mImageDisplay.getSettings().setBuiltInZoomControls(true); mImageDisplay.getSettings().setDefaultZoom(WebSettings.ZoomDensity.FAR); mImageDisplay.setVisibility(View.VISIBLE); mImageDisplay.setLayoutParams(params); // HTML is used to display the image. String html = "<body>" + constructImageElement() + "</body>"; mImageDisplay.loadDataWithBaseURL("file:///" + mInstanceFolder + File.separator, html, "text/html", "utf-8", ""); answerLayout.addView(mImageDisplay); } addAnswerView(answerLayout); }
From source file:com.nbplus.hybrid.BasicWebViewClient.java
/** * ??./* ww w . ja v a 2s. co m*/ * @param activity : context * @param view : ?? */ public BasicWebViewClient(Activity activity, WebView view, String alertTitleString, String confirmTitleString) { mWebView = view; mContext = activity; // This will handle downloading. It requires Gingerbread, though mDownloadManager = (DownloadManager) mContext.getSystemService(mContext.DOWNLOAD_SERVICE); mWebChromeClient = new BroadcastWebChromeClient(); // Enable remote debugging via chrome://inspect if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { mWebView.setWebContentsDebuggingEnabled(true); } mWebView.setWebChromeClient(mWebChromeClient); WebSettings webSettings = mWebView.getSettings(); webSettings.setGeolocationEnabled(true); webSettings.setJavaScriptCanOpenWindowsAutomatically(true); webSettings.setJavaScriptEnabled(true); webSettings.setDomStorageEnabled(true); webSettings.setDatabaseEnabled(true); // Use WideViewport and Zoom out if there is no viewport defined webSettings.setUseWideViewPort(true); webSettings.setLoadWithOverviewMode(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { webSettings.setMediaPlaybackRequiresUserGesture(false); } // Enable pinch to zoom without the zoom buttons webSettings.setBuiltInZoomControls(true); if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB) { // Hide the zoom controls for HONEYCOMB+ webSettings.setDisplayZoomControls(false); } webSettings.setAppCacheEnabled(true); mWebView.clearCache(true); webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // Sets whether the WebView should allow third party cookies to be set. // Allowing third party cookies is a per WebView policy and can be set differently on different WebView instances. // Apps that target KITKAT or below default to allowing third party cookies. // Apps targeting LOLLIPOP or later default to disallowing third party cookies. CookieManager cookieManager = CookieManager.getInstance(); cookieManager.setAcceptCookie(true); cookieManager.setAcceptThirdPartyCookies(mWebView, true); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { mWebView.getSettings().setTextZoom(100); } if (StringUtils.isEmptyString(alertTitleString)) { mAlertTitleString = activity.getString(R.string.default_webview_alert_title); } else { mAlertTitleString = alertTitleString; } if (StringUtils.isEmptyString(confirmTitleString)) { mConfirmTitleString = activity.getString(R.string.default_webview_confirm_title); } else { mConfirmTitleString = confirmTitleString; } mWebView.setDownloadListener(new DownloadListener() { public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(url)); mContext.startActivity(intent); } }); Log.d(TAG, ">> user agent = " + mWebView.getSettings().getUserAgentString()); }