public class

DataSource

extends Object
implements Parcelable
java.lang.Object
   ↳ com.google.android.gms.fitness.data.DataSource

Class Overview

Definition of a unique source of sensor data. Data sources can expose raw data coming from hardware sensors on local or companion devices. They can also expose derived data, created by transforming or merging other data sources. Multiple data sources can exist for the same data type. Every data point inserted into or read from Google Fit has an associated data source.

The data source contains enough information to uniquely identify its data, including the hardware device and the application that collected and/or transformed the data. It also holds useful metadata, such as a stream name and the device type.

The data source's data stream can be accessed in a live fashion by registering a data source listener, or via queries over fixed time intervals.

An end-user-visible name for the data stream can be set by calling setName(String) or otherwise computed from the device model and application name.

Summary

Nested Classes
class DataSource.Builder A builder that can be used to construct new data source objects. 
Constants
String EXTRA_DATA_SOURCE Name for the parcelable intent extra containing a data source.
int TYPE_DERIVED Type constant for a data source which exposes data which is derived from one or more existing data sources by performing transformations on the original data.
int TYPE_RAW Type constant for a data source which exposes original, raw data from an external source such as a hardware sensor, a wearable device, or user input.
[Expand]
Inherited Constants
From interface android.os.Parcelable
Fields
public static final Creator<DataSource> CREATOR
Public Methods
int describeContents()
boolean equals(Object that)
static DataSource extract(Intent intent)
Extracts the data source extra from the given intent, such as an intent to view user's data.
String getAppPackageName()
Returns the package name for the application responsible for setting the data, or null if unset/unknown.
DataType getDataType()
Returns the data type for data coming from this data source.
Device getDevice()
Returns the device where data is being collected, or null if unset.
String getName()
Returns the specified user-visible name for the data source, or null if unset.
String getStreamIdentifier()
Returns a unique identifier for the data stream produced by this data source.
String getStreamName()
Returns the specific name for the stream coming form this data source, or null if unset.
int getType()
Returns the constant describing the type of this data source.
int hashCode()
String toString()
void writeToParcel(Parcel parcel, int flags)
[Expand]
Inherited Methods
From class java.lang.Object
From interface android.os.Parcelable

Constants

public static final String EXTRA_DATA_SOURCE

Name for the parcelable intent extra containing a data source. It can be extracted using extract(Intent).

Constant Value: "vnd.google.fitness.data_source"

public static final int TYPE_DERIVED

Type constant for a data source which exposes data which is derived from one or more existing data sources by performing transformations on the original data.

Constant Value: 1 (0x00000001)

public static final int TYPE_RAW

Type constant for a data source which exposes original, raw data from an external source such as a hardware sensor, a wearable device, or user input.

Constant Value: 0 (0x00000000)

Fields

public static final Creator<DataSource> CREATOR

Public Methods

public int describeContents ()

public boolean equals (Object that)

public static DataSource extract (Intent intent)

Extracts the data source extra from the given intent, such as an intent to view user's data.

Returns
  • the data source, or null if not found

public String getAppPackageName ()

Returns the package name for the application responsible for setting the data, or null if unset/unknown. The PackageManager can be used to query relevant data on the application, such as the name, icon, logo, etc.

Data coming from local sensors or BLE devices will not have a corresponding application.

public DataType getDataType ()

Returns the data type for data coming from this data source. Knowing the type of data source can be useful to perform transformations on top of raw data without using sources that are themselves computed by transforming raw data.

public Device getDevice ()

Returns the device where data is being collected, or null if unset.

public String getName ()

Returns the specified user-visible name for the data source, or null if unset.

If the name is unset, the device model and app can be used as user-visible identifiers for the source.

public String getStreamIdentifier ()

Returns a unique identifier for the data stream produced by this data source. The identifier includes:

  • the physical device's manufacturer, model, and serial number (UID)
  • the application's package name (unique for a given application)
  • The data source's data type
  • the data source's type (raw or derived)
  • the data source's stream name.

public String getStreamName ()

Returns the specific name for the stream coming form this data source, or null if unset.

public int getType ()

Returns the constant describing the type of this data source.

Returns
  • one of the constant values (TYPE_DERIVED or TYPE_RAW), zero if unset. Values outside of this range should be treated as unset/unknown.

public int hashCode ()

public String toString ()

public void writeToParcel (Parcel parcel, int flags)