Всем привет, подскажите, пожалуйста, как в приложении запустить сервис в фоновом режиме без уведомления?
И что может значить то, что мое уведомление постоянно обновляется, как можно это исправить?
Сейчас использую такой код:
private void startForeground() {
Intent notificationIntent = new Intent(this, MainActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0,
notificationIntent, 0);
startForeground(NOTIF_ID, new NotificationCompat.Builder(this,
NOTIF_CHANNEL_ID) // don't forget create a notification channel first
.setOngoing(true)
.setSmallIcon(R.drawable.ic_notification)
.setContentTitle(getString(R.string.app_name))
.setContentText("Service is running background")
.setContentIntent(pendingIntent)
.build());
}
Заранее спасибо.