I have been exploring ExitApplication as a means of managing out of memory errors.
In the Starter service I have:
When the ExitApplication is executed the app dies and is immediately relaunched - but with its memory reset.
According to Erel in this post:
https://www.b4x.com/android/forum/threads/exit-application-and-activitiy-finish.26557/#post-161247
the immediate relaunch is because:
HOWEVER
In the Main activity of the app I have:
When the app is running normally (no OOM problems), if I tap the Back button (thus firing the above sub), then the app dies but is not immediately relaunched.
But the log says:
implying the Starter service was running.
This is inconsistent is it not?
In the Starter service I have:
B4X:
'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
ExitApplication
'Do not allow normal OS default exceptions handler to handle uncaught exception
Return False
End Sub
According to Erel in this post:
https://www.b4x.com/android/forum/threads/exit-application-and-activitiy-finish.26557/#post-161247
the immediate relaunch is because:
As the ExitApplication statement is in the Application_Error sub which in turn is in the Starter service then obviously a service is running and this explains why the app is immediately relaunched.ExitApplication will kill the process. If there is any service running then the process will be restarted. You should close all activities and services before calling it.
HOWEVER
In the Main activity of the app I have:
B4X:
Sub Activity_Pause(UserClosed As Boolean)
If UserClosed Then
Log("Main:Activity_Pause:IsPaused(Starter) " & IsPaused(Starter))
ExitApplication
End If
End Sub
But the log says:
B4X:
Main:Activity_Pause:IsPaused(Starter) false
This is inconsistent is it not?
Last edited: