title: android type_step_counter value stop counting up when app not in background
body: <p>I am using <code>type_step_counter</code> sensor in Service to get the step value from android phone. It gives me the value as I expected. When I close my app, shake the phone, and then open again the app, the step value from the sensor counts up (this is also as I expected). <br><br>
  However, when I swipe the app from the background, shake the phone, and then open again the app, the value from the sensor doesn't increase.<br><br>
  I read the android documentation of type_step_counter that if we want the counter to keep working while the app stopped, we should not unregister the sensor if we want it to continuously working (see <a href="https://developer.android.com/reference/android/hardware/Sensor.html#TYPE_STEP_COUNTER" rel="nofollow noreferrer">this</a>). So, I don't unregister it, but it stopped counting.
  <br><br>
  Here is my code (sorry not to put all code for security reason):<br></p>
  <pre><code>public void onCreate(){
      mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
      mStepCounterSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_STEP_COUNTER);
  }
  
  public int onStartCommand(Intent intent, int flags, int startId){
      // edited (it was unregister)
      mSensorManager.registerListener(this, mStepCounterSensor, SensorManager.SENSOR_DELAY_NORMAL); 
  
      return START_STICKY;
  }
  
  public void onSensorChanged(SensorEvent event){
      float[] values = event.values;
      Log.d(&quot;onSensorChanged&quot;, &quot;value: &quot; + String.valueOf(values[0])); // &lt;-- this value does not increase after app stopped
  }
  </code></pre>
  <p>Does anyone has any clue on this?
  Thanks in advance.</p>