It is necessary to make my Service not killed by the system and garbage cleaners.
I execute such code:
public void onCreate() { super.onCreate(); Notification.Builder builder = new Notification.Builder(this) .setSmallIcon(R.drawable.ic_launcher); builder.setContentTitle("Hello"); Notification notification; if (Build.VERSION.SDK_INT < 16) notification = builder.getNotification(); else notification = builder.build(); startForeground(777, notification); startService(); } It seems that both the picture and the label appear in the top menu, but when the cleaning is started, the Service dies and does not turn on until you start it manually.