Android Question setup LogCat to monitor all about app crash

peacemaker

Expert
Licensed User
Longtime User
Hi, All

I use LogCat standardly
B4X:
    logcat.LogCatStart(Array As String("-v","raw","*:F","B4A:v"), "logcat")
I save the log partially, some latest KBs, and today i have found that my app (camera app alway on the screen), that must work "forever" ... was just restarted. No any crash, as i can understand:

B4X:
~l374915241:timServer = ok 24.04.2020 20:41:32.036 (+03:00)
~l477667715:API_UPDATE: t3
~l577340108:API_SAVE: logs: Data saved OK (logs)
~i:** Receiver (alive) OnReceive **
~i:*** Service (starter) Create ***            'HERE IS APP RESTART' !!!! but WHY ?!
~l1719464202:Using FileProvider? true
~i:** Service (starter) Start **
~i:** Service (alive) Create **
~i:** Service (alive) Start **
~i:Service started in foreground mode.
~l2715990785:Alive: 24.04.2020 20:41:37.389 (+03:00)
~l576815746:ph_ConnectivityChanged: CONNECTED,MOBILE
~i:** Service (alive) Start **
~l6715990785:Alive: 24.04.2020 20:41:38.037 (+03:00)
~i:*** Service (ftpsrv) Create ***
~i:** Service (ftpsrv) Start **
~i:** Activity (main) Create, isFirst = true **
~l773080207:Is detector operational: false
~i:** Activity (main) Resume **
~l8712189705:numberOfCameras= 3
~l9712189710:facing: 0, 0
~i:** Activity (main) Pause, UserClosed = false **
sending message to waiting queue (CallSubDelayed - Show_Log)
~l079961477:Download_Settings 24.04.2020 20:41:39.932 (+03:00)
~l177536643:API_LOAD: commands
~i:*** Service (httputils2service) Create ***
~i:** Service (httputils2service) Start **
sending message to waiting queue (activity_permissionresult)
running waiting messages (2)
~i:** Activity (main) Resume **
~l2712189705:numberOfCameras= 3
~l3712189710:facing: 0, 0
~l4712189705:numberOfCameras= 3
~l5712189710:facing: 0, 0
~l6712255248:Preview Orientation: 0
~l773342340:PreviewSize=1920x1080
~l873407876:CaptureSize=4608x3456
~l973538951:camEx.GetPreviewSize=[Height=1080, IsInitialized=false, Width=1920
~l973538951:]
~l074915231:Send_Table: t3
....

And it's unclear what happened.
The alive Service is:
B4X:
#Region  Service Attributes
    #StartAtBoot: 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 AliveSecPeriod As Int = 30
End Sub

Sub Service_Create

End Sub

Sub Service_Start (StartingIntent As Intent)
    Log("Alive: " & others.Get_Stamp)
    If IsPaused(Starter) Then
        StartService(Starter)
    End If
    If IsPaused(Main) Then
        StartActivity(Main)
    End If
    AliveSecPeriod = 30
    Starter.timAutoStart.Interval = Starter.DefaultMsecAutoRestart
    CancelScheduledService(Me)
    StartServiceAtExact(Me, DateTime.Now + DateTime.TicksPerSecond * AliveSecPeriod, True)
    Service.StopAutomaticForeground 'Call this when the background task completes (if there is one)
End Sub

Sub Service_Destroy

End Sub

Sub ExitTemporarily(TimeoutForSeconds As Int)
    Starter.timAutoStart.Enabled = False
    Starter.timAutoStart.Interval = TimeoutForSeconds * 1000 
    Starter.timAutoStart.Enabled = True
    CancelScheduledService(Me)
    StartServiceAtExact(Me, DateTime.Now + DateTime.TicksPerSecond * TimeoutForSeconds, True)
    ExitApplication
End Sub

But i need to save the log all the time on the remote app, to analyze it later when and if any trouble is occured.
How to setup the LogCat better ?
 
Last edited:

peacemaker

Expert
Licensed User
Longtime User
It was working about 3 months. Now yes - periodical restart is used - there is very rare situation when the QR-code recognition is not started.
But anyway how to use LOgcat inside the app to control such situations ?
 
Last edited:
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
To understand what hapenned those time, why app was restarted when the app's log has nothing. Maybe to setup logging more wide, not only of my app (also add system messages) ? How ?
 
Upvote 0
Top