Fix crash when the custom tab can't open the link.

multisite
Floens 9 years ago
parent 85a8446fb6
commit ead60493a6
  1. 6
      Clover/app/src/main/java/org/floens/chan/utils/AndroidUtils.java

@ -20,6 +20,7 @@ package org.floens.chan.utils;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.app.Activity; import android.app.Activity;
import android.app.Dialog; import android.app.Dialog;
import android.content.ActivityNotFoundException;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
@ -152,7 +153,12 @@ public class AndroidUtils {
CustomTabsIntent tabsIntent = new CustomTabsIntent.Builder() CustomTabsIntent tabsIntent = new CustomTabsIntent.Builder()
.setToolbarColor(theme().primaryColor.color) .setToolbarColor(theme().primaryColor.color)
.build(); .build();
try {
tabsIntent.launchUrl(activity, Uri.parse(link)); tabsIntent.launchUrl(activity, Uri.parse(link));
} catch (ActivityNotFoundException e) {
// Can't check it beforehand so catch the exception
openIntentFailed();
}
} else { } else {
openLink(link); openLink(link);
} }

Loading…
Cancel
Save