From 2c6ca51e5c772f30490a35bf73305b43eef91b56 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Thu, 15 Aug 2019 16:25:20 +0800 Subject: Handle invalid uri when opening in Custom Tabs. --- app/src/main/java/CustomView/CustomMarkwonView.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'app/src/main/java/CustomView') diff --git a/app/src/main/java/CustomView/CustomMarkwonView.java b/app/src/main/java/CustomView/CustomMarkwonView.java index da6b2f55..d5828f13 100644 --- a/app/src/main/java/CustomView/CustomMarkwonView.java +++ b/app/src/main/java/CustomView/CustomMarkwonView.java @@ -44,7 +44,11 @@ public class CustomMarkwonView extends MarkwonView { if(uri.getHost() != null && uri.getHost().contains("reddit.com")) { customTabsIntent.intent.setPackage(context.getPackageName()); } - customTabsIntent.launchUrl(context, uri); + String uriString = uri.toString(); + if(!uriString.startsWith("http://") && (!uriString.startsWith("https://"))) { + uriString = "http://" + uriString; + } + customTabsIntent.launchUrl(context, Uri.parse(uriString)); } }).build(); -- cgit v1.2.3