I am trying to create a wrapper to the AppBugTracker android library (www.appbugtracker.com) to install an UncaughtExceptionHandler different from the B4A default.
Wrapping the library is not a problem, but after calling the init method of library (that changes the default UncaughtExceptionHandler) this seems not changed or changed again to default handler.
My wrapper create a simple Initialize method that do this:
before the AppBugTracker.init the value of UncaughtExceptionHandler was anywheresoftware.b4a.BA$1
and after the init call the method value is changed to com.appbugtracker.impl.AbtImplIncidentHandler
I call my Initialize method in Activity_Create method of my B4A application:
But when I click on the button trying to raise an exception the default handler (defined in BA static block) is used instead of com.appbugtracker.impl.AbtImplIncidentHandler as you can see in the attached screenshot.
I have also seen the thread related to ACRA :
http://www.b4x.com/android/forum/threads/trying-to-create-acra-library.19720/#post-113855
but i didn't understand how to override the exception handler.
Wrapping the library is not a problem, but after calling the init method of library (that changes the default UncaughtExceptionHandler) this seems not changed or changed again to default handler.
My wrapper create a simple Initialize method that do this:
B4X:
public static void Initialize(BA ba, String appToken) {
Context context = BA.applicationContext;
Logger.setLevel(LoggerLevel.TRACE);
Log.d("appbugtracker", "before init: " + Thread.getDefaultUncaughtExceptionHandler().getClass().getName());
com.appbugtracker.AppBugTracker.init(context, appToken);
Log.d("appbugtracker", "after init: " + Thread.getDefaultUncaughtExceptionHandler().getClass().getName());
}
before the AppBugTracker.init the value of UncaughtExceptionHandler was anywheresoftware.b4a.BA$1
and after the init call the method value is changed to com.appbugtracker.impl.AbtImplIncidentHandler
I call my Initialize method in Activity_Create method of my B4A application:
B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim abt As AppBugTracker
Dim abtToken As String = “—token-here—“
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("Layout1")
' If FirstTime Then
abt.Initialize(abtToken)
Msgbox("richiamato AppBugTracker.Initialize", "DEBUG")
' End If
Dim b As Button
b.Initialize("b")
b.Text = "Raise Exception"
Activity.AddView(b, 0, 100%y - 50dip, 100%x, 40dip)
End Sub
Sub b_Click
Dim s() As String
‘ // Raise an exception here, that should use the AppBugTracker handler
If s(0) = "a" Then ToastMessageShow(“throws exception”, False) Else ToastMessageShow(“ok”, False)
End Sub
But when I click on the button trying to raise an exception the default handler (defined in BA static block) is used instead of com.appbugtracker.impl.AbtImplIncidentHandler as you can see in the attached screenshot.
I have also seen the thread related to ACRA :
http://www.b4x.com/android/forum/threads/trying-to-create-acra-library.19720/#post-113855
but i didn't understand how to override the exception handler.