NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
builder.setContentTitle(description.getTitle())
.setAutoCancel(false);
NotificationManager notificationManager=(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Notification notificationCompat=builder.build();
notificationManager.notify(MY_ID,notificationCompat);
startForeground(MY_ID,notificationCompat);
Used above code to run service in background. But when activity closed, service call onDestroy