java.lang.Object | |
↳ | com.google.android.gms.fitness.HistoryApi.ViewIntentBuilder |
Builder of intents to view data stored in Google Fit. This intent can be used when
the application wants to display a more detailed view of a particular
data type
. Apps that can handle the data type (such as the app
that inserted the data) can register for the intent.
setPreferredApplication(String)
can be called to choose a specific
application to handle the intent, if the application is installed on the device.
This will often be the application defined in
getAppPackageName()
.
The data view intent has the following attributes:
ACTION_VIEW
MIME_TYPE_PREFIX
followed by the data type
name
.
For example, vnd.google.fitness.data_type/com.google.heart_rate.bpm
could be used
for an intent to view heart rate.
Fitness
.
<activity android:name=".ViewHeartRateActivity" android:exported="true"> <intent-filter> <action android:name="vnd.google.fitness.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <data android:mimeType="vnd.google.fitness.data_type/com.google.heart_rate.bpm" /> </intent-filter> </activity>If the application is only able to shown its own data (and not that from other apps), it can opt-out of implicit intents by removing
CATEGORY_DEFAULT
from the
intent filter above.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Starts building an intent to view History data.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns the built intent, which can be used with
startActivity(Intent) to
launch the desired Fitness activity.
| |||||||||||
Sets the data source to display data for, if a specific data source is desired.
| |||||||||||
Sets a preferred application to use for this intent.
| |||||||||||
Sets the time interval to display data for.
|
[Expand]
Inherited Methods | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Starts building an intent to view History data.
context | a valid context |
---|---|
dataType | the data type we want to visualize |
Returns the built intent, which can be used with startActivity(Intent)
to
launch the desired Fitness activity.
IllegalStateException | if not enough data has been passed into the Builder to build a valid intent. |
---|
Sets the data source to display data for, if a specific data source is desired. Otherwise, the viewer can choose any data source or use the default one.
dataSource | the specific data source we want to display data for |
---|
Sets a preferred application to use for this intent. If the given app is installed and
able to handle this intent, an explicit intent will be returned. This can be used in
combination with getAppPackageName()
to link back to the original
application which inserted the data being displayed.
packageName | the package name for the application we want to link to |
---|
Sets the time interval to display data for. Every intent requires a valid time interval.
start | start time, inclusive, in time since epoch |
---|---|
end | end time, exclusive, in time since epoch |
timeUnit | the timeUnit for start and end times |