Disable WebView touch events in Android

mWebView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } }); Disables all touch events on a WebView because the touch listener is executed before the default touch behavior of the WebView. By returning true the event is consumed and isn’t propagated to the WebView. Using android:clickable=”false” does not disable touch … Read more

Make Android WebView not store cookies or passwords

You can use this to prevent cookies from being stored and clean cookies already stored: CookieSyncManager.createInstance(this); CookieManager cookieManager = CookieManager.getInstance(); cookieManager.removeAllCookies(callback); cookieManager.setAcceptCookie(false); WebView webview = new WebView(this); WebSettings ws = webview.getSettings(); ws.setSaveFormData(false); ws.setSavePassword(false); // Not needed for API level 18 or greater (deprecated)

Webview with asynctask on Android

Don’t use AsyncTask, as you are not in charge of loading the webview. If you want to show a progress dialog, here is how to do it. private ProgressDialog dialog = new ProgressDialog(WebActivity.this); @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.webview); webView = (WebView) findViewById(R.id.webView1); Bundle extras = getIntent().getExtras(); String url=extras.getString(“adres”); webView.setWebViewClient(new WebViewClient() { @Override … Read more

Android – Choose File button in WebView

set WebChromeClient for Choose File CODE import android.app.AlertDialog; import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.view.View; import android.webkit.JavascriptInterface; import android.webkit.ValueCallback; import android.webkit.WebChromeClient; import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.ProgressBar; import android.widget.Toast; import org.apache.http.util.EncodingUtils; public class BrowserScreen extends Activity { private WebView webView; private String url = “url”; private ValueCallback<Uri> mUploadMessage; private final static int … Read more

Android webview cannot render youtube video embedded via iframe

If you want to play videos within your WebView you NEED to load the data with a base URL! DONT do this: mContentWebView.loadDataWithBaseURL(null, webViewContentString, “text/html”, “UTF-8”, null); DO THIS INSTEAD: //veryVeryVery important for playing the videos! mContentWebView.loadDataWithBaseURL(theBaseUrl, webViewConentString, “text/html”, “UTF-8″, null); The Base URL will be the something like the “original” url of what you … Read more