Not enough information...
Is this the starter service?
Are you changing the automatic foreground mode?
Also post the full error message.
		
		
	 
I have been reading on the internet on this subject, and I have found in:   https:// medium.com/pongploydev/why-start-the-service-on-android-o-and-encounter-a-problem-record-context-startforegroundservice-3c8ddd8969ef
This paragraph:
"After the system creates the service, the app has 5 seconds to call the service’s startForeground() method to display the user-visible notification for the new service. If the app does not call startForeground() within this time limit, the system will stop the service and declare the application as ANR."
I use the code from your example "Background location tracking" - 
https://www.b4x.com/android/forum/threads/background-location-tracking.99873/#content
But I added that: -> when the "user_is_tracking=false" does not execute tracker tracking, and I end the service with: "lock.ReleasePartialLock & Service.StopAutomaticForeground".... code:
	
	
	
	
	
	
	
	
	
		#Region  Service Attributes
    #StartAtBoot: True
#End Region
Sub Process_Globals
    Dim user_is_tracking As Boolean
    Private nid As Int = 1
    Private GPS As GPS
    Private Tracking As Boolean
    Private LastUpdateTime As Long
    Private lock As PhoneWakeState
End Sub
Sub Service_Create
    Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_NEVER 'we are handling it ourselves
    GPS.Initialize("gps")
    lock.PartialLock
End Sub
Sub Service_Start (StartingIntent As Intent)
    If user_is_tracking Then
        Service.StartForeground(nid, CreateNotification("..."))
        StartServiceAt(Me, DateTime.Now + 30 * DateTime.TicksPerMinute, True)
        Track
    Else
        lock.ReleasePartialLock
        Service.StopAutomaticForeground 'Starter service can start in the foreground state in some edge cases.
    End If
End Sub
Public Sub Track
    If Tracking Then Return
    If Starter.rp.Check(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION) = False Then
        Log("No permission")
        Return
    End If
    GPS.Start(0, 0)
    Tracking = True
End Sub
.
.
.
	 
	
	
		
	
 
I think that I do not close the service well, and those 5 seconds are indicated and the system stops the service declaring application as ANR.
This is correct? How can it be solved?
thanks 
