我有一个Android应用程序,使用服务来收听位置更新 . 由于有关后台服务的新奥利奥政策,我正在更新应用程序以使用前台服务,以便操作系统不会破坏服务 . 我只是通过调用:

@Override
public int onStartCommand(Intent intent, int flags, int startId) {

    startForeground(
            NotificationsHelper.getNewNotificationID(this), //this will retrieve my singleton id
            NotificationsHelper.getNotification(this, false) // this will create the notification object
    );

    return Service.START_STICKY;
}

现在,另一个服务使用相同的通知,因此我使用相同的通知ID执行相同的通知 .

由于为第二个服务重新创建了通知,两个服务是否仍然被认为是前台服务(因此Oreo不会破坏它们)?

另外,如果我在我的代码中的其他地方重新创建相同的通知,总是使用相同的ID,我的服务是否仍然被考虑在前台(再次没有被奥利奥摧毁)?

基本上,与用于启动前台服务的通知具有相同ID的通知是否活动(即使重新创建)以使服务成为前台服务并且因此不会被操作系统销毁?