Move:
SensorManager sm = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
if(sm.getSensorList(Sensor.TYPE_GYROSCOPE).size() != 0)
{
Sensor s = sm.getSensorList(Sensor.TYPE_GYROSCOPE).get(0);
sm.registerListener(this, s, SensorManager.SENSOR_DELAY_GAME);
}
Into your Service's onCreate(). getSystemService()
is a method in Context, which the Service extends. However, you do not have a Context until onCreate() has been called. Therefore, this results in an NPE in the constructor.
Also, make sure you're starting the Service using startService(), and not creating a normal Java object from it