Erro startForeground após atualização para Android 8.1: como corrigir?
Olá a todos! Estou desenvolvendo um aplicativo em Kotlin que usa um serviço em background para rastrear localização. Após atualizar o dispositivo para Android 8.1 (Oreo), meu serviço parou de funcionar e cai com o erro `Context.startForegroundService() did not then call Service.startForeground()`. Aqui está meu código do service:
```kotlin
class LocationService : Service() {
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
val notification = NotificationCompat.Builder(this, "channel_id")
.setContentTitle("Serviço ativo")
.setContentText("Rastreamento de localização")
.setSmallIcon(R.drawable.ic_location)
.build()
startForeground(1, notification)
return START_STICKY
}
override fun onBind(intent: Intent?): IBinder? = null
}
```
E estou iniciando assim:
```kotlin
val intent = Intent(this, LocationService::class.java)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {