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 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.
| |||||||||||
Obfuscates a data source's package name, stream name, and device information (name is
not obfuscated).
| |||||||||||
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.
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.
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.
Sets the data type for the data source. Every data source is required to have a data type.
dataType | one of the data types defined in DataType , or a custom data type
|
---|
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.
Sets an end-user-visible name for this data source. This is optional.
Obfuscates a data source's package name, stream name, and device information (name is not obfuscated). The obfuscated attributes will be returned when an application other than the original one queries the data source. Data from this data source will still be visible to other applications, but the data source identifying attributes will be hidden.
Note that obfuscating a data source has important implications. Other applications being used to display the data won't be able to give attribution of the source, or to link back to it via intents. Because of this, applications may also decide to filter obfuscated sources
isObfuscated | whether the source should be obfuscated. Sources are non-obfuscated by default. |
---|
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.
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.