title: How to properly implement a sensor with SensorManager in a thread?
body: <p>I've got this command on my thread, but it doesn't work: <code>sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);</code></p>
  
  <p>I want to make sensor background listener without my app being opened.</p>
  
  <pre class="lang-java prettyprint-override"><code>public class myThread extends Thread implements SensorEventListener{
      public SensorManager sensorManager;
      @Override
      public void run()
      {
          sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
          sensorManager.registerListener(this, sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_NORMAL);
  </code></pre>
  
  <p>I've got an error <code>Cannot resolve method 'getSystemService(?)'</code>.</p>