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 = "stardustapk@gmail.com"
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.
logs.Initialize
#if RELEASE
logcat.LogCatStart(Array As String("-v","raw","*:F","B4A:v"), "logcat")
#end if
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
Private Sub logcat_LogCatData (Buffer() As Byte, Length As Int)
logs.Append(BytesToString(Buffer, 0, Length, "utf8"))
If logs.Length > 5000 Then
logs.Remove(0,logs.Length - 4000)
End If
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 l As Long = 500
jo.InitializeStatic("java.lang.Thread").RunMethod("sleep", Array(l))
logcat.LogCatStop
logs.Append(StackTrace).Append(CRLF).Append(Error)
Dim email As Email
email.To.Add(emailAddress)
email.Subject = "Primanota Pro - crashed"
email.Body = logs
StartActivity(email.GetIntent)
Return True
End Sub
Sub Service_Destroy
End Sub