Fall back to application's icon

Closes #10
This commit is contained in:
Nathan Kerr 2019-08-29 14:20:15 -07:00
parent 53f3278722
commit 8ad9802ea6

View File

@ -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("")) {