Android Sensor System


Authors

Dr. Richard Fletcher (fletcher@media.mit.edu), Olufemi Omojola (oluseyi@alum.mit.edu)

Introduction

This document describes an Android sensor system that is designed to accelerate the development of sensors on the Android platform. It provides an integrated framework with support for both sensor hardware providers and client software developers. It simplifies the development of sensor support packages on the Android platform by providing code templates and leverages the capabilities of the Android Intent system to provide discovery of new sensors, seamless support for multiple independent sensor that provide similar measurements, and loose coupling between client programs and sensor suites.

Notes

The source code provided requires the use of the Eclipse development environment with the Android plugins.

Background

The base specification for the sensor system is available here. This document discusses a sample implentation that complies with the spec and goes over a number of the relevant details in depth.

Implementation Outline

A compliant sensor suite is an Android package (apk file) that (at a minimum) provides the following functionality:
  • A BroadcastReceiver that extends either edu.mit.media.sensor.common.SingleSensorInformationResponder or edu.mit.media.sensor.common.MultiSensorInformationResponder and has an IntentFilter that accepts Intents with an action set to android.intent.Intent.ACTION_PICK and a data type set to application/vnd.sensor. This allows sensor support enumeration to be performed using Android broadcast Intents.
  • A configuration Activity that has an IntentFilter that accepts Intents with an action set to android.intent.Intent.ACTION_EDIT, a data type set to the specific sensor's mime-type, and a category set to android.intent.category.DEFAULT. This supports configuration of the sensor.
  • A capture Activity that has an IntentFilter that accepts Intents with an action set to android.intent.Intent.ACTION_GET_CONTENT, a data type set to the specific sensor's mime-type, and a category set to android.intent.category.DEFAULT. This supports capture of sensor data.
  • A viewing or rendering Activity that has an IntentFilter that accepts Intents with an action set to android.intent.Intent.ACTION_VIEW, a data type set to the specific sensor's mime-type, and a category set to android.intent.category.DEFAULT. This supports rendering of sensor data.
Note that one can implement multiple functions in a single Activity: for example implementing both capture and viewing in the same Activity to leverage common resources and reduce the size of the entire sensor suite.

Sensor Management Suite

A sensor management application that provides discovery of installed sensor suites as well as (limited) testing and exploration of the functionality of installed sensor suites can be installed using this link. The source code can also be downloaded from here.This application allows:
  • Android broadcast based discovery of installed sensor suites.
  • Access to the configuration, capture and viewing Activities of each sensor suite. Content provider based implementations are not supported.
This can be used to test and verify any sensor suite implementation.

Sensor Suite Support Library

For developers of sensor support suites, a support library that contains helpful classes can be downloaded here. This includes:
  • An abstract class that can be extended to provide a default configuration Activity: this is useful for sensors that don't make configuration options available.
  • Abstract classes that can be exteded to implement BroadcastReceivers that are compliant with the sensor discovery process.

Sample Sensor Suite Implementation: Compass

Using the sensor support library above, we have implemented a reference sensor support suite for the built-in compass in Android devices: this is based on the compass demonstration software available from the Android developer website. This reference suite can be downloaded in compiled form here, and in source form here.

Copyright © 2010 - 2012 MIT Media Lab. All rights reserved.