From 8600ce8d8a56398a4eb731f0cccb848c4e18d2eb Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Thu, 1 Feb 2018 14:37:29 +0100 Subject: [PATCH] prevent crashes from update notifications on < android-11 closes #1306 * https://stackoverflow.com/questions/3112008/android-java-lang-illegalargumentexception-contentintent-required-error-cause * https://stackoverflow.com/questions/20032249/is-setcontentintentpendingintent-required-in-notificationcompat-builder --- app/src/main/java/org/fdroid/fdroid/NotificationHelper.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/src/main/java/org/fdroid/fdroid/NotificationHelper.java b/app/src/main/java/org/fdroid/fdroid/NotificationHelper.java index 00ce60cbe..1f5fa61b5 100644 --- a/app/src/main/java/org/fdroid/fdroid/NotificationHelper.java +++ b/app/src/main/java/org/fdroid/fdroid/NotificationHelper.java @@ -433,6 +433,12 @@ class NotificationHelper { intentDeleted.setClass(context, NotificationBroadcastReceiver.class); PendingIntent piDeleted = PendingIntent.getBroadcast(context, 0, intentDeleted, PendingIntent.FLAG_UPDATE_CURRENT); builder.setDeleteIntent(piDeleted); + + if (Build.VERSION.SDK_INT < 11) { + Intent intent = new Intent(); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + builder.setContentIntent(PendingIntent.getActivity(context, 0, intent, 0)); + } return builder.build(); }