private Notification getForegroundNotification(int allowed, int blocked) { Intent main = new Intent(this, ActivityMain.class); PendingIntent pi = PendingIntent.getActivity(this, 0, main, PendingIntent.FLAG_UPDATE_CURRENT); TypedValue tv = new TypedValue(); getTheme().resolveAttribute(R.attr.colorPrimary, tv, true); NotificationCompat.Builder builder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_security_white_24dp) .setContentTitle(getString(R.string.app_name)) .setContentText(getString(R.string.msg_started)) .setContentIntent(pi) .setCategory(Notification.CATEGORY_STATUS) .setVisibility(Notification.VISIBILITY_SECRET) .setPriority(Notification.PRIORITY_MIN) .setColor(tv.data) .setOngoing(true) .setAutoCancel(false); if (allowed > 0 || blocked > 0) { NotificationCompat.BigTextStyle notification = new NotificationCompat.BigTextStyle(builder); notification.bigText(getString(R.string.msg_started)); notification.setSummaryText(getString(R.string.msg_packages, allowed, blocked)); return notification.build(); } else return builder.build(); }