Android Webview App: srolling & mailto links

I wrote myself a little android app, which is nothing more than a webview – calling a web page not from the android browser but within the app. During the process I encountered a few problems with my Samsung Galaxy SIII:

1. the scrolling plugins (jquery autoscoll, touchcarousel) didn’t work

Only by accident I stumbled across iscroll-4, where I learned how to cope with this problem:

document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);

And after that, everything worked like a charm!

2. mailto links were not handled correctly

This problem needs to be taken care of by changing something within your app program. in WebViewClient extended I modified shouldOverrideUrlLoading a little:

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            if(url.startsWith("mailto:")){
                MailTo mt = MailTo.parse(url);
                Intent i = newEmailIntent(CreareActivity.this, mt.getTo(), mt.getSubject(), mt.getBody(), mt.getCc());
                startActivity(i);
                view.reload();
                return true;
            }else{          
                view.loadUrl(url);
            }
            return true;
        }

Thanks a lot for this entry at stackoverflow !

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.