public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId) { if (intent.Action.Equals(Constants.ACTION_START_SERVICE)) { if (isStarted) { //Log.Info(TAG, "OnStartCommand: The service is already running."); } else { viktem = new Victim(); //to add //BleAdapter = App.BLEAcrProfileManager.bleprofile.BleAdapter; bleProfile = App.BLEAcrProfileManager.bleprofile; /*subNoTIFYB = bleProfile.CharacteristicRead.SubscribeToNotifications().Subscribe(result => * { * /* result.Characteristic.SubscribeToNotifications().Subscribe * (x => this.SetReadValueB(x, true));*/ /* if (result.Data != null) * PostData(); * * });*/ //Log.Info(TAG, "OnStartCommand: The service is starting."); RegisterForegroundService(); handler.PostDelayed(runnable, Constants.DELAY_BETWEEN_LOG_MESSAGES); isStarted = true; } } else if (intent.Action.Equals(Constants.ACTION_STOP_SERVICE)) { //Log.Info(TAG, "OnStartCommand: The service is stopping."); //timestamper = null; StopForeground(true); StopSelf(); isStarted = false; } else if (intent.Action.Equals(Constants.ACTION_RESTART_TIMER)) { // Log.Info(TAG, "OnStartCommand: Restarting the timer."); //timestamper.Restart(); } // This tells Android not to restart the service if it is killed to reclaim resources. return(StartCommandResult.Sticky); }
public BLEAcrProfileManager() { bleprofile = new BLEAcrProfile(); bleprofile.BleAdapter = CrossBleAdapter.Current; }