Android Question Reconnect FusedLocationProvider after Suspend

AHilberink

Active Member
Licensed User
Longtime User
Hi,

I want to restart my Location service based on FusedLocationProvider after getting a Suspend_by_Disconnected cause.

I try:
B4X:
Sub GPSTrack_ConnectionSuspended(SuspendedCause1 As Int)
    Dim Cause As String
    
    Log("ConnectionSuspended")
    If(SuspendedCause1=GPSTrack1.SuspendedCause.CAUSE_NETWORK_LOST) Then
        Cause="Suspended by NetworkLost"
    Else If(SuspendedCause1=GPSTrack1.SuspendedCause.CAUSE_SERVICE_DISCONNECTED) Then
        Cause="Suspended by Disconnected"
    Else
        Cause="Suspended: Unknow cause"
    End If
    DateTime.DateFormat="dd-MM-yyyyy"
    Cause=Cause&": "&DateTime.date(DateTime.Now)&"_"&DateTime.Time(DateTime.Now)
    Log(Cause)
    GPSTrack1.Disconnect
    FromFailed=FromFailed+1
    GPSTrack1.Connect
End Sub

It seems not working.

Is this the rigth way or is it possible to do it another way? I need my service to be up 24/7. For the service it is working, but Location is gone from time to time.

Kind regards,
André
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…