Android Question Reading logs remotely [SOLVED]

AHilberink

Active Member
Licensed User
Longtime User
Check whether your app is killed while it is in the background. You can see it in the logs.

May be a simple question: How can see it in the logs, while the device is remote? I do have Crashlytics active.

Kind regards,
André
 

DonManfred

Expert
Licensed User
Longtime User
May be a simple question: How can see it in the logs, while the device is remote? I do have Crashlytics active.
You´ll find a stacktrace in Crashlytics Console when your app crashes.

You can not see the complete log in the console. At least i don´t know a way.
 
Upvote 0

AHilberink

Active Member
Licensed User
Longtime User
You´ll find a stacktrace in Crashlytics Console when your app crashes.

You can not see the complete log in the console. At least i don´t know a way.

Thanks DonManfred.

That is my problem. The App does not crash.

The following is happening:
The user is starting an order to drive to a location. His appointment is active in my form. From this he can start an Intent to Maps. During running maps, my App seems to be reset (killed?) after a while. It is still selectable on the square button, but the form is empty and also my background service (AutomaticForeground_Always/PartialLock) for GPSLocation is stopped.

Erel mentioned my App is killed in the background during to long inactivity and mentioned to look the logs.

I now changed my service with:
B4X:
StartServiceAt(Me, DateTime.Now + 30 * DateTime.TicksPerMinute, True)
to restarts the service.

Now my service looks like:
B4X:
#Region  Service Attributes
    #StartAtBoot: False
    #ExcludeFromLibrary: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Dim lock As PhoneWakeState
    Dim LatLonOud As Location
    Dim GPSTrack As FusedLocationProvider
    Dim Route As List
    Dim RouteTijd As List
    Dim OpnemenRoute As Boolean
End Sub

Sub Service_Create
    If(LatLonOud.IsInitialized=False) Then LatLonOud.Initialize
    If(Route.IsInitialized=False) Then Route.Initialize
    If(RouteTijd.IsInitialized=False) Then RouteTijd.Initialize
    If(GPSTrack.IsInitialized=False) Then GPSTrack.Initialize("GPSTrack")
    'Service.AutomaticForegroundNotification=RemoveIcon
    Service.AutomaticForegroundMode=Service.AUTOMATIC_FOREGROUND_NEVER
    lock.PartialLock
End Sub

Sub Service_Start (StartingIntent As Intent)
    Service.StartForeground(999,RemoveIcon)
    StartServiceAt(Me, DateTime.Now + 30 * DateTime.TicksPerMinute, True)
    Track
End Sub

Sub Service_TaskRemoved
    'This event will be raised when the user removes the app from the recent apps list.
End Sub

'Return true to allow the OS default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
    Return True
End Sub

Sub Service_Destroy
    Log("Destroyed2")
    If GPSTrack.IsConnected Then
        GPSTrack.Disconnect
        Route.Clear
        RouteTijd.Clear
    End If
    'lock.ReleasePartialLock
End Sub

Public Sub Track
    Log("GPSTrack is ON")
    If (GPSTrack.IsConnected) Then Return
    If (Starter.rp.Check(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION)=False) Then
        Log("No permission")
        Return
    Else
        GPSTrack.Connect
    End If
End Sub

Sub GPSTrack_ConnectionSuccess
    Dim LocationRequest1 As LocationRequest
    LocationRequest1.Initialize
    LocationRequest1.SetInterval(20000)         '1000 is 1 seconde
    LocationRequest1.SetPriority(LocationRequest1.Priority.PRIORITY_BALANCED_POWER_ACCURACY) '.PRIORITY_HIGH_ACCURACY)
    Dim LocationSettingsRequestBuilder1 As LocationSettingsRequestBuilder
    LocationSettingsRequestBuilder1.Initialize
    LocationSettingsRequestBuilder1.AddLocationRequest(LocationRequest1)
    GPSTrack.CheckLocationSettings(LocationSettingsRequestBuilder1.Build)
    GPSTrack.RequestLocationUpdates(LocationRequest1)
End Sub

Sub GPSTrack_LocationSettingsChecked(LocationSettingsResult1 As LocationSettingsResult)
End Sub

Sub RemoveIcon As Notification
    Dim ic As Notification
    
    ic.Initialize2(ic.IMPORTANCE_LOW)
    ic.Icon="empty"
    ic.Sound=False
    ic.SetInfo("","",Null)
    Return ic
End Sub

Sub GPSTrack_LocationChanged(Location1 As Location)
    Dim HTTPLocatie As HttpJob
    Dim DatumTijd As String

    If(Starter.GPSLoc) Then
        If(Location1.DistanceTo(LatLonOud)/1000>0.1) Then '100m
            Log("GPS verzonden")
            HTTPLocatie.Initialize("",Me)
            HTTPLocatie.Download(......&lat="&Location1.Latitude&"&lon="&Location1.Longitude)
            Wait For (HTTPLocatie) JobDone(HTTPLocatie As HttpJob)
            If(HTTPLocatie.Success = True) Then
            Else
            End If
            HTTPLocatie.Release
        End If
    End If

    If(OpnemenRoute) Then
        If(Location1.DistanceTo(LatLonOud)/1000>0.5) Then '500m
            DateTime.DateFormat="dd-MM-yyyy"
            DatumTijd=DateTime.Date(DateTime.Now)&"/"&DateTime.Time(DateTime.Now)
            Route.Add(Location1)
            RouteTijd.Add(DatumTijd)
        End If
    End If

    LatLonOud=Location1
End Sub

Will this prevent also my Activity (Form) from being killed?

Kind regards,
André
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Will this prevent also my Activity (Form) from being killed?
probably no. This is expected and you need to adapt your app to work with this situation.
The app must be able to reinitialize anything needed when started again.

This is probably not the case.
 
Upvote 0
Top