Hi everybody,
I want to capture a CrashLog in the starter service as described here and it works fine if I start the intent to send it by email.
But if I try an HTTP post to silent send it to my server nothing is sent (I suppose the app terminate before the post is executed). Also I see I can't use Wait For after the post.
This is my code. Any suggestion ?
P.S. I've already implemented and worked with CrashLytics but I don't like it too much. Managing the reports in my server would be more efficient.
I want to capture a CrashLog in the starter service as described here and it works fine if I start the intent to send it by email.
But if I try an HTTP post to silent send it to my server nothing is sent (I suppose the app terminate before the post is executed). Also I see I can't use Wait For after the post.
This is my code. Any suggestion ?
P.S. I've already implemented and worked with CrashLytics but I don't like it too much. Managing the reports in my server would be more efficient.
B4X:
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
Dim jo As JavaObject
Dim l As Long = 500
jo.InitializeStatic("java.lang.Thread").RunMethod("sleep", Array(l))
logcat.LogCatStop
CrashLog.Append(StackTrace)
CrashLog.Append(CRLF & CRLF & "Crashreport created " & DateTime.Date(DateTime.Now))
Dim ll As Map
ll.Initialize
ll.Put("DeviceID",Main.DeviceID)
ll.Put("Type", "AND")
ll.Put("Manufacturer",Main.DeviceManufacturer)
ll.Put("Model", Main.DeviceModel)
ll.Put("Log",CrashLog)
Dim j As HttpJob
j.Initialize("j", Me)
Dim pm As PackageManager
Dim Reflector1 As Reflector
ll.Put("ApiLevel", Reflector1.GetStaticField("android.os.Build$VERSION", "SDK_INT"))
Dim ps As String="clientid=" & Main.DeviceID _
& "&type=2" & "&msgtype=CrashReport" & "&cmdbody=" & MySub.MapToString(ll) & "&apilevel=" & Reflector1.GetStaticField("android.os.Build$VERSION", "SDK_INT")
j.PostString ("http://" & MySub.EBServerAddress & ":" & MySub.EBServerPort & "/devicecommand", ps)
Return True
End Sub