@Override
  public void onCreate() {
    super.onCreate();

    binder = binderBuilder.build(this);

    sensorManager = (SensorManager) getApplication().getSystemService(SENSOR_SERVICE);
    accelorometerSensor = sensorManager.getDefaultSensor(SensorManager.SENSOR_ACCELEROMETER);

    sensorChangeMonitor.setSensorChangeListener(this);
  }
  @Override
  public void onDestroy() {
    binder = null;
    binderBuilder = null;
    sensorManager = null;
    accelorometerSensor = null;
    sensorChangeMonitor = null;

    stopAlarmService();

    super.onDestroy();
  }
 @Override
 public int onStartCommand(Intent intent, int flags, int startId) {
   super.onStartCommand(intent, flags, startId);
   if (db == null) {
     android.os.Process.setThreadPriority(Process.THREAD_PRIORITY_FOREGROUND);
     dbHelper = new DatabaseHelper(getApplicationContext());
     db = dbHelper.getWritableDatabase();
     dataHelper = DataHelper.getInstance(getApplicationContext());
     appChangeReceiver = new ApplicationChangeReceiver();
     screenStateReceiver = new ScreenStateReceiver();
     remoteLoggingReceiver = new RemoteLoggingReceiver();
     registerReceiver(screenStateReceiver, screenStateReceiver.buildIntentFilter());
     startRemoteLogging();
     startTimeCount();
   }
   return START_STICKY;
 }
 @Override
 public void onTaskRemoved(Intent rootIntent) {
   restartService();
   super.onTaskRemoved(rootIntent);
 }
 @Override
 public void onDestroy() {
   super.onDestroy();
   mAnalytics.stop();
 }
 @Override
 public void onStart(Intent intent, int startId) {
   super.onStart(intent, startId);
   mAnalytics.start();
 }