|
@@ -24,11 +24,13 @@ package uk.co.md87.android.contextanalyser;
|
24
|
24
|
|
25
|
25
|
import android.app.Service;
|
26
|
26
|
import android.content.Intent;
|
|
27
|
+import android.content.pm.PackageManager.NameNotFoundException;
|
27
|
28
|
import android.location.Address;
|
28
|
29
|
import android.location.Geocoder;
|
29
|
30
|
import android.location.Location;
|
30
|
31
|
import android.os.Handler;
|
31
|
32
|
import android.os.IBinder;
|
|
33
|
+import android.telephony.TelephonyManager;
|
32
|
34
|
import android.util.Log;
|
33
|
35
|
import com.flurry.android.FlurryAgent;
|
34
|
36
|
|
|
@@ -39,6 +41,7 @@ import java.util.Iterator;
|
39
|
41
|
import java.util.LinkedList;
|
40
|
42
|
import java.util.List;
|
41
|
43
|
import java.util.Map;
|
|
44
|
+import uk.co.md87.android.common.ExceptionHandler;
|
42
|
45
|
|
43
|
46
|
import uk.co.md87.android.common.ModelReader;
|
44
|
47
|
import uk.co.md87.android.common.accel.AccelReaderFactory;
|
|
@@ -105,6 +108,10 @@ public class ContextAnalyserService extends Service {
|
105
|
108
|
public void onCreate() {
|
106
|
109
|
super.onCreate();
|
107
|
110
|
|
|
111
|
+ Thread.setDefaultUncaughtExceptionHandler(
|
|
112
|
+ new ExceptionHandler("ContextAnalyser",
|
|
113
|
+ "http://chris.smith.name/android/upload", getVersionName(), getIMEI()));
|
|
114
|
+
|
108
|
115
|
locationMonitor = new LocationMonitorFactory().getMonitor(this);
|
109
|
116
|
|
110
|
117
|
aggregator = new AutoAggregatorFactory().getAutoAggregator(this, handler,
|
|
@@ -119,6 +126,18 @@ public class ContextAnalyserService extends Service {
|
119
|
126
|
|
120
|
127
|
FlurryAgent.onStartSession(this, "MKB8YES3C6CFB86PXYXK");
|
121
|
128
|
}
|
|
129
|
+
|
|
130
|
+ public String getVersionName() {
|
|
131
|
+ try {
|
|
132
|
+ return getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
|
|
133
|
+ } catch (NameNotFoundException ex) {
|
|
134
|
+ return "Unknown";
|
|
135
|
+ }
|
|
136
|
+ }
|
|
137
|
+
|
|
138
|
+ public String getIMEI() {
|
|
139
|
+ return ((TelephonyManager) getSystemService(TELEPHONY_SERVICE)).getDeviceId();
|
|
140
|
+ }
|
122
|
141
|
|
123
|
142
|
public void poll() {
|
124
|
143
|
handler.postDelayed(scheduleRunnable, POLLING_DELAY);
|