when do:
the stopservice, Cancel the 'startserviceat' previous?
i need a service always running (every 10 minuts cath GPS location), and the service are destroyed.
i read a lotof messages in forum, but i can't understand the process
i include in service this cote too:
and
B4X:
Sub Service_Start (StartingIntent As Intent)
Try
Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_ALWAYS
flp.Initialize("flp")
flp.Connect
IniciarGPSPlus
StartServiceAt(Me, DateTime.Now + Intervalo * 60 * 1000 ,True )
End If
Service.StopAutomaticForeground 'Starter service can start in the foreground state in some edge cases.
Catch
Log(LastException)
End Try
End Sub
Sub GPS_LocationChanged (Location1 As Location)
Try
LocationUltima = Location1
Log(Location1)
modGeneral.SetLocation(Location1, ForzarDeteccionGPSXFIREBASE)
SaveModoYPosicionAndSTOP( ForzarDeteccionGPSXFIREBASE)
ForzarDeteccionGPSXFIREBASE = False
StopService(Me)
Catch
Log(LastException)
End Try
End Sub
the stopservice, Cancel the 'startserviceat' previous?
i need a service always running (every 10 minuts cath GPS location), and the service are destroyed.
i read a lotof messages in forum, but i can't understand the process
i include in service this cote too:
B4X:
#Region Service Attributes
#StartCommandReturnValue: android.app.Service.START_STICKY
#StartAtBoot: false
#End Region
and
B4X:
Sub Service_Create
Try
'Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_ALWAYS 'we are handling it ourselves
lock.PartialLock
flp.Initialize("flp")
flp.Connect
IniciarGPSPlus
Catch
'ToastMessageShow("Service Create: " & LastException.Message,True)
Log(LastException)
End Try
End Sub