From 8ad9802ea6528b0df6171511258d76d76389efc9 Mon Sep 17 00:00:00 2001 From: Nathan Kerr Date: Thu, 29 Aug 2019 14:20:15 -0700 Subject: [PATCH] Fall back to application's icon Closes #10 --- src/android/ForegroundService.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/android/ForegroundService.java b/src/android/ForegroundService.java index 80223e0..c0edae6 100644 --- a/src/android/ForegroundService.java +++ b/src/android/ForegroundService.java @@ -196,11 +196,16 @@ public class ForegroundService extends Service { Intent intent = context.getPackageManager() .getLaunchIntentForPackage(pkgName); + int smallIcon = getIconResId(settings); + if (smallIcon == 0) { //If no icon at all was found, fall back to the app's icon + smallIcon = context.getApplicationInfo().icon; + } + NotificationCompat.Builder notification = new NotificationCompat.Builder(context, CHANNEL_ID) .setContentTitle(title) .setContentText(text) .setOngoing(true) - .setSmallIcon(getIconResId(settings)) + .setSmallIcon(smallIcon) .setShowWhen(settings.optBoolean("showWhen", true)); if (!subText.equals("")) {