Bucket | Android Developers

Quicknav Quicknav
Links

- Google Play Developer Console
- Android Developers Blog
- About Android

Android Sites

- Android.com
- Android Developers
- Android Open Source Project

Language
close

- - About
  - Wear
  - TV
  - Auto
- - Get Started
  - Devices
  - Style
  - Patterns
  - Building Blocks
  - Downloads
  - Videos
- - Training
  - API Guides
  - Reference
  - Tools
  - Google Services
  - Samples
- - Google Play
  - Essentials
  - Get Users
  - Engage & Retain
  - Monetize
  - Analyze
  - Tools & Reference
  - Developer Stories

## Results

Loading...
Summary: Constants | Inherited Constants | Fields | Methods | Inherited Methods | [Expand All]
public class

# Bucket

extends Object
implements Parcelable

java.lang.Object
↳ | com.google.android.gms.fitness.data.Bucket

## Class Overview

A bucket represents a time interval over which aggregated data is computed. For example, a bucket can represent user's average speed and average heart rate over a 1 hour interval. Currently we allow buckets to be computed by only one of the following strategies:

1. time: a time bucket can represent a full day, hour, or any other desired interval
2. session: a session bucket represents data for one session
3. activity type: an activity type represents one of the `FitnessActivities`
4. activity segments: an activity segment represents data for one activity segment

A Bucket consists of the following fields:

- startTime denotes the start time of the bucket. This field is always present.
- endTime denotes the end time of the bucket. This field is always present.
- session denotes the associated session with the bucket. This is an optional field that is set only if the read query had requested bucketing by sessions.
- activity denotes the associated activity with the bucket as defined in `FitnessActivities`. This is an optional field and is set only if the read query had requested bucketing of data by activity segments.
- dataSets `DataSets` for the aggregated `data types` requested in the read query over the time interval of this bucket.
- bucketType denotes if the bucketing is by time, session or activity. This field is always present and set to one of `TYPE_TIME`, `TYPE_SESSION`, `TYPE_ACTIVITY_SEGMENT` or `TYPE_ACTIVITY_TYPE`.

## Summary

Constants
int | TYPE_ACTIVITY_SEGMENT | Type constant denoting that bucketing by individual activity segment is requested.
int | TYPE_ACTIVITY_TYPE | Type constant denoting that bucketing by activity type is requested.
int | TYPE_SESSION | Type constant denoting that bucketing by session is requested.
int | TYPE_TIME | Type constant denoting that bucketing by time is requested.

[Expand] Inherited Constants
From interface android.os.Parcelable
int | CONTENTS_FILE_DESCRIPTOR |
int | PARCELABLE_WRITE_RETURN_VALUE |

Fields
public static final Creator<Bucket> | CREATOR |

Public Methods
int | describeContents()
boolean | equals(Object o)
String | getActivity() Returns the activity of the bucket if bucketing by activity was requested, or `UNKNOWN` otherwise.
int | getBucketType() Returns the type of the bucket.
DataSet | getDataSet(DataType dataType) Returns the data set of requested data type over the time interval of the bucket.
List<DataSet> | getDataSets() Returns the requested data sets over the time interval of the bucket.
long | getEndTime(TimeUnit timeUnit) Returns the end time of the bucket, in the given time unit since epoch.
Session | getSession() Returns the session of the bucket if bucketing by session was requested, `null` otherwise.
long | getStartTime(TimeUnit timeUnit) Returns the start time of the bucket, in the given time unit since epoch.
int | hashCode()
String | toString()
void | writeToParcel(Parcel dest, int flags)

[Expand] Inherited Methods
From class java.lang.Object
Object | clone()
boolean | equals(Object arg0)
void | finalize()
final Class<?> | getClass()
int | hashCode()
final void | notify()
final void | notifyAll()
String | toString()
final void | wait()
final void | wait(long arg0, int arg1)
final void | wait(long arg0)
From interface android.os.Parcelable
abstract int | describeContents()
abstract void | writeToParcel(Parcel arg0, int arg1)

## Constants

#### public static final int TYPE_ACTIVITY_SEGMENT

Type constant denoting that bucketing by individual activity segment is requested.

Constant Value: 4 (0x00000004)

#### public static final int TYPE_ACTIVITY_TYPE

Type constant denoting that bucketing by activity type is requested.

Constant Value: 3 (0x00000003)

#### public static final int TYPE_SESSION

Type constant denoting that bucketing by session is requested.

Constant Value: 2 (0x00000002)

#### public static final int TYPE_TIME

Type constant denoting that bucketing by time is requested.

Constant Value: 1 (0x00000001)

## Fields

#### public static final Creator<Bucket> CREATOR

## Public Methods

#### public int describeContents ()

#### public boolean equals (Object o)

#### public String getActivity ()

Returns the activity of the bucket if bucketing by activity was requested, or `UNKNOWN` otherwise.

#### public int getBucketType ()

Returns the type of the bucket.

#### public DataSet getDataSet (DataType dataType)

Returns the data set of requested data type over the time interval of the bucket. Returns null, if data set for the requested type is not found.

#### public List<DataSet> getDataSets ()

Returns the requested data sets over the time interval of the bucket.

#### public long getEndTime (TimeUnit timeUnit)

Returns the end time of the bucket, in the given time unit since epoch.

#### public Session getSession ()

Returns the session of the bucket if bucketing by session was requested, `null` otherwise.

#### public long getStartTime (TimeUnit timeUnit)

Returns the start time of the bucket, in the given time unit since epoch.

#### public int hashCode ()

#### public String toString ()

#### public void writeToParcel (Parcel dest, int flags)