title: SensorEventListener in a service
body: <p>im trying to implement the SensorEventListener but for some reason nothing happend.
  ive tired to created a separate class for the listener but its still not working.
  the service is running in a separate thread.(in the manifest android:process=":myproces")</p>
  
  <pre><code>public class Servicee extends Service {
  private SensorManager sensorManager;
  private long lastUpdate;
  SensorEventListener listen;
  
  @Override
  public IBinder onBind(Intent intent) {
      // TODO Auto-generated method stub
      return null;
  }
  @Override
  public int onStartCommand(Intent intent, int flags, int startId) {
      // TODO Auto-generated method stub
      sensorManager = (SensorManager) getApplicationContext()
              .getSystemService(SENSOR_SERVICE);
      lastUpdate = System.currentTimeMillis();
      listen = new SensorListen();
      return START_STICKY;
  }
  @Override
  public void onCreate() {
      // TODO Auto-generated method stub
      Toast.makeText(getApplicationContext(), "Started", 1000).show();
      super.onCreate();
  }
  
  private void getAccelerometer(SensorEvent event) {
      float[] values = event.values;
      // Movement
      float x = values[0];
      float y = values[1];
      float z = values[2];
  
      float accelationSquareRoot = (x * x + y * y + z * z)
              / (SensorManager.GRAVITY_EARTH * SensorManager.GRAVITY_EARTH);
      long actualTime = System.currentTimeMillis();
      if (accelationSquareRoot &gt;= 7) //
      {
          if (actualTime - lastUpdate &lt; 2000) {
              return;
          }
          lastUpdate = actualTime;
          Toast.makeText(this,
                  "Device was shuffed _ " + accelationSquareRoot,
                  Toast.LENGTH_SHORT).show();
          Vibrator v = (Vibrator) getApplicationContext().getSystemService(VIBRATOR_SERVICE);
          v.vibrate(1000);
          Intent startMain = new Intent(Intent.ACTION_MAIN);
          startMain.addCategory(Intent.CATEGORY_HOME);
          startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
          startActivity(startMain);
      }
  }
  
  @Override
  public void onDestroy() {
      // TODO Auto-generated method stub
      sensorManager.unregisterListener(listen);
      Toast.makeText(this, "Destroy", Toast.LENGTH_SHORT).show();
      super.onDestroy();
  }
  public class SensorListen implements SensorEventListener{
  
      @Override
      public void onSensorChanged(SensorEvent event) {
          // TODO Auto-generated method stub
          if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
              getAccelerometer(event);
          }
      }
  
      @Override
      public void onAccuracyChanged(Sensor sensor, int accuracy) {
          // TODO Auto-generated method stub
  
      }
  
  }
  </code></pre>
  
  <p>what could possibly be wrong with it?</p>