Hi all,
I am facing a problem with an app I am building and uses two services. The two services are the Starter service and an other service. The other service is started at user's will and at some point crashes. I cannot find the crash point with Debug mode because my app uses the Google Play Services which are not present in the emulator and further more the second service responds to the accelerometer's values changing which cannot be tested in the emulator. In order to find out what is wrong I added the following code to the Application_Error sub of the Starter service. Yet I cannot find what is wrong with the second service because it never reaches the Application_Error sub to send me the error logs and the sub the error occured (sSub changes each time the code execution enters a new sub in order to catch the sub that has the error). Instead I get an error message "App was interrupted" (I do not know if I am translating it right because I see it in Greek). What am I doing wrong?
This is my code in the Starter service:
I am facing a problem with an app I am building and uses two services. The two services are the Starter service and an other service. The other service is started at user's will and at some point crashes. I cannot find the crash point with Debug mode because my app uses the Google Play Services which are not present in the emulator and further more the second service responds to the accelerometer's values changing which cannot be tested in the emulator. In order to find out what is wrong I added the following code to the Application_Error sub of the Starter service. Yet I cannot find what is wrong with the second service because it never reaches the Application_Error sub to send me the error logs and the sub the error occured (sSub changes each time the code execution enters a new sub in order to catch the sub that has the error). Instead I get an error message "App was interrupted" (I do not know if I am translating it right because I see it in Greek). What am I doing wrong?
This is my code in the Starter service:
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.
Private logs As StringBuilder
Private logcat As LogCat
Private const emailAddress As String = "bogus@yahoo.com"
Public sSub As String
End Sub
Sub Service_Create
'This is the program entry point.
'This is a good place to load resources that are not specific to a single activity.
End Sub
Sub Service_Start (StartingIntent As Intent)
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
'wait for 500ms to allow the logs to be updated.
Dim jo As JavaObject
Dim lngWait As Long = 500
jo.InitializeStatic("java.lang.Thread").RunMethod("sleep", Array(lngWait))
logcat.LogCatStop
logs.Append("Sub:" & sSub).Append(CRLF).Append(CRLF)
logs.Append(StackTrace).Append(CRLF).Append(CRLF).Append(Error.Message)
Dim email As Email
email.To.Add(emailAddress)
email.Subject = "The app crashed"
email.Body = logs.ToString
StartActivity(email.GetIntent)
Return True
End Sub
Sub Service_Destroy
End Sub