SwipeRefreshLayout + WebView when scroll position is at top

I’ve managed to solve it without having to extend anything. Have a look at this snippet (Fragment-specific): private ViewTreeObserver.OnScrollChangedListener mOnScrollChangedListener; @Override public void onStart() { super.onStart(); swipeLayout.getViewTreeObserver().addOnScrollChangedListener(mOnScrollChangedListener = new ViewTreeObserver.OnScrollChangedListener() { @Override public void onScrollChanged() { if (mWebView.getScrollY() == 0) swipeLayout.setEnabled(true); else swipeLayout.setEnabled(false); } }); } @Override public void onStop() { swipeLayout.getViewTreeObserver().removeOnScrollChangedListener(mOnScrollChangedListener); super.onStop(); } For … Read more

Webview email link (mailto)

You have to create a subclass of WebViewClient and override mailto URL loading. Example: public class MyWebViewClient extends WebViewClient { private final WeakReference<Activity> mActivityRef; public MyWebViewClient(Activity activity) { mActivityRef = new WeakReference<Activity>(activity); } @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { if (url.startsWith(“mailto:”)) { final Activity activity = mActivityRef.get(); if (activity != null) { MailTo … Read more

Intercept POST requests in a WebView

I was facing the same issue a few days ago. So I built a library that solves it: https://github.com/KonstantinSchubert/request_data_webviewclient It is a WebViewClient with a custom WebResourceRequest that contains the POST/PUT/… payload of XMLHttpRequest requests. It only works for these though – not for forms and other kind of request sources. The hack works, basically, … Read more

In Android Webview, am I able to modify a webpage’s DOM?

To expand on CommonsWare’s correct answer: WebView webview = new WebView(); webview.setWebViewClient(new WebClient()); webView.getSettings().setJavaScriptEnabled(true); webview.loadUrl(“stackoverflow.com”); then in WebClient: public class WebClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } @Override public void onPageFinished(WebView view, String url) { // Obvious next step is: document.forms[0].submit() view.loadUrl(“javascript:document.forms[0].q.value=”[android]””); } } In a … Read more

Android webview loading data performance very slow

I think the following works best: if (Build.VERSION.SDK_INT >= 19) { webView.setLayerType(View.LAYER_TYPE_HARDWARE, null); } else { webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null); } Android 19 has Chromium engine for WebView. I guess it works better with hardware acceleration. For more info Android 4.4 KitKat, the browser and the Chrome WebView Hardware Acceleration also do’s the trick.You can use it … Read more

Android WebView Hardware Acceleration Artefact Workarounds

add: -webkit-backface-visibility: hidden; -webkit-perspective: 1000; backface-visibility: hidden; perspective: 1000; if you working with 3d transform.. it is a cheap trick BUT it will improve the performance espacially on iPad.. furthermore you can try to -webkit-transform: rotateZ(0deg); AFAIK rotations can boost the performance because gpu´s are much better in rotating something.. another way is to lay … Read more

onShowFileChooser() from android webview works only once

firstly, sorry to my english. you should return empty Uri[]{} to file receive mUploadMessageForAndroid5.onReceiveValue(new Uri[]{}); my code can choose take photo or local image: private static final int REQUEST_GET_THE_THUMBNAIL = 4000; private static final long ANIMATION_DURATION = 200; public final static int FILECHOOSER_RESULTCODE = 1; public final static int FILECHOOSER_RESULTCODE_FOR_ANDROID_5 = 2; //JS webView.getSettings().setJavaScriptEnabled(true); //set … Read more

WebView textarea doesn’t pop up the keyboard

The full solution is a bit more than what Sana had. It is documented as a bug over at the Android site ( http://code.google.com/p/android/issues/detail?id=7189 ): webView.requestFocus(View.FOCUS_DOWN); webView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_UP: if (!v.hasFocus()) { v.requestFocus(); } break; } return false; } });