Back to project page rcdroid.
The source code is released under:
Copyright (c) 2013, Jamie Furness (jamie@jamierf.co.uk) All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following...
If you think the Android project rcdroid listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.jamierf.rcdroid.input; /* www . j a v a 2s . co m*/ import android.content.Context; import android.hardware.SensorManager; import android.location.LocationManager; import com.jamierf.rcdroid.input.sensor.AccelerationSensor; import com.jamierf.rcdroid.input.sensor.BatterySensor; import com.jamierf.rcdroid.input.sensor.LocationSensor; import com.jamierf.rcdroid.input.sensor.RotationSensor; import com.jamierf.rcdroid.input.sensor.listener.SensorListener; public class SensorController { private final LocationSensor location; private final AccelerationSensor acceleration; private final RotationSensor rotation; private final BatterySensor battery; public SensorController(final Context context) { final SensorManager sensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE); final LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); location = new LocationSensor(locationManager); acceleration = new AccelerationSensor(sensorManager); rotation = new RotationSensor(sensorManager); battery = new BatterySensor(context); } public void addAccelerationListener(SensorListener<AccelerationSensor> listener) { acceleration.addListener(listener); } public void addLocationListener(SensorListener<LocationSensor> listener) { location.addListener(listener); } public void addRotationListener(SensorListener<RotationSensor> listener) { rotation.addListener(listener); } public void addBatteryListener(SensorListener<BatterySensor> listener) { battery.addListener(listener); } public void forceUpdate() { location.forceUpdate(); acceleration.forceUpdate(); rotation.forceUpdate(); battery.forceUpdate(); } public void close() { location.close(); acceleration.close(); rotation.close(); battery.close(); } }