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)
Dim email As Email
email.To.Add(emailAddress)
email.Subject = "Program crashed"
email.Body = logs
Dim in As Intent = email.GetIntent
in.Flags = Bit.Or(0x10000000, 0x00008000)
StartActivity(in)
Return True
End Sub