diff --git a/src/com/btmura/android/reddit/app/LinkFragment.java b/src/com/btmura/android/reddit/app/LinkFragment.java index 20f8ed3a..05c4ff96 100644 --- a/src/com/btmura/android/reddit/app/LinkFragment.java +++ b/src/com/btmura/android/reddit/app/LinkFragment.java @@ -18,9 +18,12 @@ import android.annotation.SuppressLint; import android.app.AlertDialog; +import android.content.ActivityNotFoundException; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; +import android.content.Intent; import android.graphics.Bitmap; +import android.net.Uri; import android.os.Bundle; import android.support.v4.app.Fragment; import android.text.TextUtils; @@ -84,6 +87,19 @@ private void setupWebView(WebView webView) { webView.setOnLongClickListener(this); webView.setWebViewClient(new WebViewClient() { + @Override + public boolean shouldOverrideUrlLoading(WebView view, String url) { + if (url == null || url.startsWith("http://") || url.startsWith("https://")) { + return false; + } + try { + startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); + return true; + } catch (ActivityNotFoundException e) { + return false; + } + } + @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { if (progress != null) {