@Override
  public void onDestroy() {
    db.close();
    dbHelper.close();
    unregisterReceiver(screenStateReceiver);

    // Doing something else to notify
    restartService();
  }
 @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;
 }