Skip to Content
Pro Android Apps Performance Optimization
book

Pro Android Apps Performance Optimization

by Hervé Guihot
January 2012
Intermediate to advanced
282 pages
7h 4m
English
Apress
Content preview from Pro Android Apps Performance Optimization

Sensors

Sensors are fun. Everybody likes them and everybody wants to use them. The way to use sensors is very similar to the way to use location providers: your application registers a sensor listener with a specific sensor and is notified of updates. Listing 7–15 shows how you can register a listener with the device’s accelerometer.

Listing 7–15. Registering Sensor Listener With Accelerometer

    private void registerWithAccelerometer() {         SensorManager sm = (SensorManager) getSystemService(Context.SENSOR_SERVICE);         List<Sensor> sensors = sm.getSensorList(Sensor.TYPE_ACCELEROMETER);         if (sensors != null&& ! sensors.isEmpty()) {             SensorEventListener listener = new SensorEventListener() {                 @Override ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Android High Performance Programming

Android High Performance Programming

Enrique López Mañas, Diego Grancini
Pro Android Graphics

Pro Android Graphics

Wallace Jackson

Publisher Resources

ISBN: 9781430239994Purchase book