From 2c0e6d5ffed0ff0160d80c99d5cf066ab0ddc613 Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 21 Dec 2019 21:52:23 +0100 Subject: [PATCH] Prevent crash --- app/src/main/java/eu/faircode/email/FragmentOAuth.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentOAuth.java b/app/src/main/java/eu/faircode/email/FragmentOAuth.java index 270d17e214..45a5fb18d6 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOAuth.java +++ b/app/src/main/java/eu/faircode/email/FragmentOAuth.java @@ -19,6 +19,7 @@ package eu.faircode.email; Copyright 2018-2019 by Marcel Bokhorst (M66B) */ +import android.content.ActivityNotFoundException; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; @@ -240,7 +241,10 @@ public class FragmentOAuth extends FragmentBase { if (BuildConfig.DEBUG) Log.i("OAuth uri=" + authRequest.toUri()); Intent authIntent = authService.getAuthorizationRequestIntent(authRequest); - startActivityForResult(authIntent, ActivitySetup.REQUEST_OAUTH); + if (authIntent.resolveActivity(getContext().getPackageManager()) == null) + throw new ActivityNotFoundException(authIntent.toString()); + else + startActivityForResult(authIntent, ActivitySetup.REQUEST_OAUTH); } catch (Throwable ex) { showError(ex); }