java.lang.Object | |
↳ | com.google.android.gms.fitness.data.DataSource.Builder |
A builder that can be used to construct new data source objects. In general, a built data source should be saved in memory to avoid the cost of re-constructing it for every request.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Finishes building the data source and returns a DataSource object.
| |||||||||||
Sets the package name for the application that is recording or computing the data.
| |||||||||||
Sets the package name for the application that is recording or computing the data based on
the app's context.
| |||||||||||
Sets the list of data quality standards adhered to by this data source.
| |||||||||||
Sets the data type for the data source.
| |||||||||||
Sets the integrated device where data is being recorded (for instance, a phone that has
sensors, or a wearable).
| |||||||||||
Sets an end-user-visible name for this data source.
| |||||||||||
The stream name uniquely identifies this particular data source among other data sources of
the same type from the same underlying producer.
| |||||||||||
Sets the type of the data source.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Finishes building the data source and returns a DataSource object.
Returns | |
---|---|
DataSource |
Throws | |
---|---|
IllegalStateException |
if the builder didn't have enough data to build a valid data source. |
Sets the package name for the application that is recording or computing the data. Used for data sources that aren't built into the platform (local sensors and BLE sensors are built-in). It can be used to identify the data source, to disambiguate between data from different applications, and also to link back to the original application for a detailed view.
Parameters | |
---|---|
packageName |
String
|
Returns | |
---|---|
DataSource.Builder |
Sets the package name for the application that is recording or computing the data based on
the app's context. This method should be preferred when an application is creating a data
source that represents its own data. When creating a data source to query data from other
apps, setAppPackageName(String)
should be used.
Parameters | |
---|---|
appContext |
Context
|
Returns | |
---|---|
DataSource.Builder |
Sets the list of data quality standards adhered to by this data source.
This field is ignored by all Fit APIs. It exists so that developers may create DataSource
objects for testing which will return a value from getDataQualityStandards()
. In DataSource
objects returned by Fit APIs, the data
quality standards list is set from an internally maintained mapping.
Parameters | |
---|---|
dataQualityStandards |
int
|
Returns | |
---|---|
DataSource.Builder |
Sets the data type for the data source. Every data source is required to have a data type.
Parameters | |
---|---|
dataType |
DataType :
one of the data types defined in DataType , or a custom data type
|
Returns | |
---|---|
DataSource.Builder |
Sets the integrated device where data is being recorded (for instance, a phone that has
sensors, or a wearable). Can be useful to identify the data source, and to disambiguate
between data from different devices. If the data is coming from the local device, use Device.getLocalDevice(Context)
.
Note that it may be useful to set the device even if the data is not coming from a hardware sensor on the device. For instance, if the user installs an application which generates sensor data in two separate devices, the only way to differentiate the two data sources is using the device. This can be specially important if both devices are used at the same time.
Parameters | |
---|---|
device |
Device
|
Returns | |
---|---|
DataSource.Builder |
Sets an end-user-visible name for this data source. This is optional.
Parameters | |
---|---|
name |
String
|
Returns | |
---|---|
DataSource.Builder |
The stream name uniquely identifies this particular data source among other data sources of the same type from the same underlying producer. Setting the stream name is optional, but should be done whenever an application exposes two streams for the same data type, or when a device has two equivalent sensors.
The stream name is used by getStreamIdentifier()
to make sure the different streams are properly separated when
querying or persisting data.
Parameters | |
---|---|
streamName |
String
|
Returns | |
---|---|
DataSource.Builder |
Throws | |
---|---|
IllegalArgumentException |
if the specified stream name is null |
Sets the type of the data source. TYPE_DERIVED
should be used if any
other data source is used in generating the data. TYPE_RAW
should be used
if the data comes completely from outside of Google Fit.
Parameters | |
---|---|
type |
int
|
Returns | |
---|---|
DataSource.Builder |