Skip to content

Instantly share code, notes, and snippets.

/myservice class Secret

Created March 20, 2016 08:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/a27dd9d91c59a731c14a to your computer and use it in GitHub Desktop.
Save anonymous/a27dd9d91c59a731c14a to your computer and use it in GitHub Desktop.
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
if(intent.getAction().equals("start"))
{
sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
sensor = sensorManager.getDefaultSensor(Sensor.TYPE_LIGHT);
sensorManager.registerListener(this, sensor,
SensorManager.SENSOR_DELAY_FASTEST);
}
else if(intent.getAction().equals("stop"))
{
stopSelf();
}
return START_STICKY;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment