androidwear-osandroid-sensorsgoogle-fitandroid-hardware

Difference between android.hardware.Sensor and Fitness.SENSORS_API


I'm looking for the difference between android.hardware.Sensor and Fitness.SENSORS_API in term of performance, simplicity.

Because I saw on Sensor API doc:

The API exposes data sources from hardware sensors in the local device and in companion devices. It also exposes data sources from applications. Data sources can be queried via findDataSources(GoogleApiClient, DataSourcesRequest)

After searching on Google, I saw that there exist android.hardware.Sensor.

So my question is, what is the difference between these two in terms of performance, simplicity, and other parameters?

Is there an existing better way to use a sensor in order to record the steps or activity recognition for example?

Have a good day guys!


Solution

  • Explaining the usage of both would be considered too broad for Stack Overflow. Pretty sure that the documentation for both should cover most of the topics you usually need to know.

    However, to give you a simple comparison, the Sensor API is responsible for sending the (fitness) details from a stream of data. From the docs (emphasis mine):

    The API exposes data sources from hardware sensors in the local device and in companion devices.

    "hardware sensors" here, (usually) refers to the built-in Android Hardware Sensors or from an Android Wear device (or something similar).