From aed89d8503eabb8f79debc6f2e557918d7be8143 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Katzer?= Date: Wed, 17 Aug 2016 13:26:47 +0200 Subject: [PATCH] Fix wrong icon resource --- src/android/ForegroundService.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/android/ForegroundService.java b/src/android/ForegroundService.java index be85163..9cc1de5 100644 --- a/src/android/ForegroundService.java +++ b/src/android/ForegroundService.java @@ -93,7 +93,7 @@ public class ForegroundService extends Service { * Put the service in a foreground state to prevent app from being killed * by the OS. */ - public void keepAwake() { + private void keepAwake() { JSONObject settings = BackgroundMode.getSettings(); boolean isSilent = settings.optBoolean("silent", false); @@ -101,7 +101,8 @@ public class ForegroundService extends Service { startForeground(NOTIFICATION_ID, makeNotification()); } - PowerManager powerMgr = (PowerManager) getSystemService(POWER_SERVICE); + PowerManager powerMgr = (PowerManager) + getSystemService(POWER_SERVICE); wakeLock = powerMgr.newWakeLock( PowerManager.PARTIAL_WAKE_LOCK, "BackgroundMode"); @@ -174,7 +175,7 @@ public class ForegroundService extends Service { * @param settings * The config settings */ - public void updateNotification (JSONObject settings) { + protected void updateNotification (JSONObject settings) { boolean isSilent = settings.optBoolean("silent", false); if (isSilent) { @@ -202,6 +203,12 @@ public class ForegroundService extends Service { String pkgName = context.getPackageName(); String icon = settings.optString("icon", "icon"); - return res.getIdentifier(icon, "drawable", pkgName); + int resId = res.getIdentifier(icon, "drawable", pkgName); + + if (resId == 0) { + resId = res.getIdentifier("icon", "drawable", pkgName); + } + + return resId; } }