Sub Name: ReportError
Description: Have your app email an error report to you.
This gets asked for often in the chat room. It sends an error report to you with the following information from your app:
App name
App version
Phone make and model
Full java stack trace
Include this in your app or in a data module. Surround important areas that you want reports from with a Try Catch statement. Call the ReportError sub in the Catch clause so it will only be executed on an error. That's it!
You can call this from as many subs as you like. Anywhere that you want to be notified of an error. To use the stack trace that is generated, go to your project directory and look in the Objects\src folder. You will see more folders that are the same as your project name such as:
Objects\src\org\mlsoft\VirtualDyno
Then you'll see various java files there. The one you want is main.java. Open that file and go to the line number reported in the error report. Above it, you will see a b4a reference line number. That is the line number to look at in the b4a IDE to find the error.
You will need to add the following libraries to your project:
Phone library
Threading library
StringUtils library
pname is the name of the app
ver is the version of the app
inetAddress is your email address (where you want the report to go)
Tags email,error,report
Description: Have your app email an error report to you.
This gets asked for often in the chat room. It sends an error report to you with the following information from your app:
App name
App version
Phone make and model
Full java stack trace
Include this in your app or in a data module. Surround important areas that you want reports from with a Try Catch statement. Call the ReportError sub in the Catch clause so it will only be executed on an error. That's it!
You can call this from as many subs as you like. Anywhere that you want to be notified of an error. To use the stack trace that is generated, go to your project directory and look in the Objects\src folder. You will see more folders that are the same as your project name such as:
Objects\src\org\mlsoft\VirtualDyno
Then you'll see various java files there. The one you want is main.java. Open that file and go to the line number reported in the error report. Above it, you will see a b4a reference line number. That is the line number to look at in the b4a IDE to find the error.
You will need to add the following libraries to your project:
Phone library
Threading library
StringUtils library
pname is the name of the app
ver is the version of the app
inetAddress is your email address (where you want the report to go)
B4X:
Sub ReportError(pName As String, Ver As String, inetAddress As String)
Dim ex As ExceptionEx 'from the Threading library
Dim error,ptype As String 'the error string and phone type info
Dim mail As Email 'built in email type
ex.Initialize(LastException.Message)
ptype = ph.Manufacturer & " " & ph.Model & CRLF & pName & " version " & Ver & CRLF
error = ptype & CRLF & ex.ToString & CRLF & CRLF & ex.StackTrace & CRLF
If Msgbox2("An error has occurred. The error is : "&LastException.Message&". Please report this error below.","ERROR","Report","","Dismiss",Null) = DialogResponse.POSITIVE Then
mail.Attachments.Clear
mail.Subject= pName & " error" 'Example: Virtual Dyno error
mail.To.Add(inetAddress)
mail.Body= error
StartActivity(mail.GetIntent) 'calls the intent to show the email client
End If
End Sub
Tags email,error,report