-
Notifications
You must be signed in to change notification settings - Fork 40
E2-1372 : Add crash handler code #202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| @@ -0,0 +1,5 @@ | |||
| package com.leanplum.monitoring; | |||
|
|
|||
| public interface LeanplumCrashReporting { | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's rename this to ExceptionReporter
| import java.lang.reflect.Constructor; | ||
|
|
||
| public class LeanplumCrashHandler { | ||
| private static final String RAYGUN_CRASH_REPORTER_CLASS = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RAYGUN_CRASH_REPORTER_CLASS_NAME
| public class LeanplumCrashHandler { | ||
| private static final String RAYGUN_CRASH_REPORTER_CLASS = | ||
| "com.leanplum.monitoring.internal.RaygunCrashReporter"; | ||
| private static final LeanplumCrashHandler ourInstance = new LeanplumCrashHandler(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just instance
|
|
||
| import java.lang.reflect.Constructor; | ||
|
|
||
| public class LeanplumCrashHandler { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the class name can be just CrashHandler, it already lives in package com.leanplum.monitoring
|
|
||
| public void setContext(Context context) { | ||
| try { | ||
| Class<?> clazz = Class.forName(RAYGUN_CRASH_REPORTER_CLASS); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of using reflection to try to instantiate the class, we can just let the crash reporter register a factory, if it's loaded by the jvm.
so this CrashHandler can just expose a register method:
static void registerCrashReporterFactory(CrashReporterFactory crashReportFactory) {
reporterFactory = crashReporterFactory;
}
then in setContext()
public void setContext(Context context) {
if (reporterFactory != null) {
crashReporter = crashReporterFactory.create(context);
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Who calls registerCrashReporterFactory ? In my design, the module can just be added and won't need any additional code, hence reflection
|
test this please |
1 similar comment
|
test this please |
|
|
||
| JSONObject responseBody; | ||
| HttpURLConnection op = null; | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revert ?
The Android SDK needs to report crashes. We will add another repo which will provide different crash reporting services to the main repo. This commit adds the interface for a raygun provider