Is it time to charge your devices.?

Check out this charging station!

Android Webview open link in browser, if you are using an android Webview in your app but would like to open some type of URL’s in your phones default browser like Chrome or Firefox, here is what you need to do.

Android Webview open link in browser code snippet

You need to override WebViewClient’s shouldOverrideUrlLoading like so:

myWebWiev = (WebView)findViewById(R.id.myWebWiev);
myWebWiev.setWebViewClient(new WebViewClient() {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            // open in Webview
            if (url.contains("android_asset") ){  
            // Can be clever about it like so where myshost is defined in your strings file
            // if (Uri.parse(url).getHost().equals(getString(R.string.myhost)))  
                return false;
            }
           // open rest of URLS in default browser
            Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
            startActivity(intent);
            return true;
        }
    });

For more Android related posts check out my Android category page.

Have fun! and please Like♥ the page if you found this useful!

Please feel free to add your own solutions in the comments!

Photo credit to etnyk at Flickr.

Cheers!