-
Notifications
You must be signed in to change notification settings - Fork 246
Expand file tree
/
Copy pathDroidPlannerServicesApp.java
More file actions
61 lines (46 loc) · 1.84 KB
/
Copy pathDroidPlannerServicesApp.java
File metadata and controls
61 lines (46 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package org.droidplanner.services.android;
import android.app.Application;
import com.crashlytics.android.Crashlytics;
import org.droidplanner.services.android.utils.LogToFileTree;
import org.droidplanner.services.android.utils.analytics.GAUtils;
import org.droidplanner.services.android.utils.file.IO.ExceptionWriter;
import io.fabric.sdk.android.Fabric;
import timber.log.Timber;
public class DroidPlannerServicesApp extends Application {
private LogToFileTree logToFileTree;
@Override
public void onCreate() {
super.onCreate();
if(BuildConfig.ENABLE_CRASHLYTICS) {
Fabric.with(this, new Crashlytics());
}
if (BuildConfig.WRITE_LOG_FILE) {
logToFileTree = new LogToFileTree();
Timber.plant(logToFileTree);
} else if (BuildConfig.DEBUG) {
Timber.plant(new Timber.DebugTree());
}
final ExceptionWriter exceptionWriter = new ExceptionWriter(getApplicationContext());
final Thread.UncaughtExceptionHandler defaultHandler = Thread.getDefaultUncaughtExceptionHandler();
final Thread.UncaughtExceptionHandler handler = new Thread.UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread thread, Throwable ex) {
exceptionWriter.saveStackTraceToSD(ex);
defaultHandler.uncaughtException(thread, ex);
}
};
Thread.setDefaultUncaughtExceptionHandler(handler);
GAUtils.initGATracker(this);
GAUtils.startNewSession(null);
}
public void createFileStartLogging() {
if (logToFileTree != null) {
logToFileTree.createFileStartLogging(getApplicationContext());
}
}
public void closeLogFile() {
if(logToFileTree != null) {
logToFileTree.stopLoggingThread();
}
}
}