public TestService()
 {
     _sbr = new ServiceBroadcastReceiver();
     _sbr.ReceiveMessage += (context, intent) =>
                                {
                                    var cType = (AppConstants.ServiceCommandType) intent.GetIntExtra(AppConstants.COMMAND_TYPE_ID, -1);
                                    switch (cType)
                                    {
                                        case AppConstants.ServiceCommandType.SendPing:
                                            {
                                                Log.Info("TestService", "Ping received");
                                                break;
                                            }
                                        case AppConstants.ServiceCommandType.StopService:
                                            {
                                                Log.Info("TestService", "Service stopping...");
                                                StopSelf();
                                                break;
                                            }
                                        default:
                                            {
                                                Log.Info("TestService", "Unknown Command: {0}", cType.ToString());
                                                break;
                                            }
                                    }
                                };
 }
        public override void OnCreate()
        {
            Log.Info("LMService.OnCreate", string.Format("In OnCreate"));
            base.OnCreate();

            _repository = new Repository<GeographicData>(this);

            _sbr = new ServiceBroadcastReceiver();
            _sbr.ReceiveMessage += (context, intent) =>
                                       {
                                           var cType = (AppConstants.ServiceCommandType) intent.GetIntExtra(AppConstants.COMMAND_TYPE_ID, -1);
                                           switch (cType)
                                           {
                                               case AppConstants.ServiceCommandType.SendPing:
                                                   {
                                                       Log.Info("TestService", "Ping received");
                                                       var pongIntent = new Intent(AppConstants.APPLICATION_COMMAND);
                                                       pongIntent.PutExtra(AppConstants.COMMAND_TYPE_ID, (int)AppConstants.ApplicationCommandType.ReceivePong);
                                                       Log.Info("TestService", "Sending pong!");
                                                       SendBroadcast(pongIntent);
                                                       break;
                                                   }
                                               case AppConstants.ServiceCommandType.StopService:
                                                   {
                                                       Log.Info("TestService", "Service stopping...");
                                                       ExportData();
                                                       StopSelf();
                                                       break;
                                                   }
                                               case AppConstants.ServiceCommandType.ExportData:
                                                   {
                                                       ExportData();
                                                       break;
                                                   }
                                               default:
                                                   {
                                                       Log.Info("TestService", "Unknown Command: {0}", cType.ToString());
                                                       break;
                                                   }
                                           }
                                       };

            _notificationManager = (NotificationManager) GetSystemService(Context.NotificationService);
            ShowNotification();
            var criteria = new Criteria
                               {
                                   Accuracy = Accuracy.Fine,
                                   PowerRequirement = Power.Medium,
                                   AltitudeRequired = false,
                                   BearingRequired = false,
                                   SpeedRequired = false,
                                   CostAllowed = false,
                               };
            _locationManager = (LocationManager) GetSystemService(Context.LocationService);

            // !!! Remember to enable the location permissions in the project attributes or _bestProvider comes back null :)
            // you will also need to ensure that the container class either inherits from Service or Activity, or it goes all crashy;
            // but you'll see a build warning about it implementing IJavaObject but not inheriting from Java.Object
            _bestProvider = _locationManager.GetBestProvider(criteria, false);
            // Location _location = _locationManager.GetLastKnownLocation(_bestProvider);
            // at least 15 seconds between updates, at least 100 metres between updates, 'this' because it implements ILocationListener.
            _locationManager.RequestLocationUpdates(_bestProvider, 15000, 100, this);
        }