예제 #1
0
 /** Starts the service and binds the activity to it. */
 private void StartAndBindService() {
   Utilities.LogDebug("StartAndBindService - binding now");
   serviceIntent = new Intent(this, GpsLoggingService.class);
   // Start the service in case it isn't already running
   startService(serviceIntent);
   // Now bind to service
   bindService(serviceIntent, gpsServiceConnection, Context.BIND_AUTO_CREATE);
   Session.setBoundToService(true);
 }
예제 #2
0
  /** Stops the service if it isn't logging. Also unbinds. */
  private void StopAndUnbindServiceIfRequired() {
    Utilities.LogDebug("GpsMainActivity.StopAndUnbindServiceIfRequired");
    if (Session.isBoundToService()) {
      unbindService(gpsServiceConnection);
      Session.setBoundToService(false);
    }

    if (!Session.isStarted()) {
      Utilities.LogDebug("StopServiceIfRequired - Stopping the service");
      // serviceIntent = new Intent(this, GpsLoggingService.class);
      stopService(serviceIntent);
    }
  }