title: Android: onSensorChanged() not called despite attaching listener
body: <p>Couldn't find a solution from the existing posts. I'm trying to build a step counter using Android's built in TYPE_STEP_COUNTER sensor but the onSensorChange() method doesn't get called! In the below code, for example, "Outside <em>stepcount</em>" is never printed to the Logcat.</p>
  
  <pre><code>public class StepFragment extends Fragment implements SensorEventListener {
  
  private int step_count = 0;
  TextView stepCountText;
  private Sensor mStepSensor;
  private SensorManager mSensorManager;
  
  @Nullable
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
      View view = inflater.inflate(R.layout.stepfragment, container, false);
      stepCountText = (TextView)view.findViewById(R.id.stepcounttext);
      return view;
  }
  
  @Override
  public void onActivityCreated(@Nullable Bundle savedInstanceState) {
      super.onActivityCreated(savedInstanceState);
      mSensorManager = (SensorManager) getActivity().getSystemService(SENSOR_SERVICE);
      mStepSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_STEP_COUNTER);
  }
  
  
      @Override
      public void onAccuracyChanged(Sensor sensor, int accuracy) {
  
      }
  
      @Override
      public void onSensorChanged(SensorEvent event) {
          System.out.println("Outside" + step_count);
          if (event.values[0] == 1.0f) {
              step_count++;
              System.out.println(step_count);
          }
          stepCountText.setText(Integer.toString(step_count));
      }
  
  @Override
  public void onResume() {
      super.onResume();
      mSensorManager.registerListener(this, mStepSensor, SensorManager.SENSOR_DELAY_NORMAL);
      if(mStepSensor != null)
      {
          System.out.println("Sensor step counter present");
      }
  }
  
  @Override
  public void onPause() {
      super.onPause();
      mSensorManager.unregisterListener(this);
      System.out.println("Fragment Paused");
  }
  }
  </code></pre>
  
  <p>I do get "Sensor step counter present" in my Logcat which proves that my device indeed has the step_counter sensor. I'd be very grateful for some help!</p>