com.google.android.gms.fitness.data.Field

Here are the examples of the java api class com.google.android.gms.fitness.data.Field taken from open source projects.

1. Mission#onDataPoint()

View license
@Override
public void onDataPoint(DataPoint dataPoint) {
    // If we get data before the mission has started, discard them.
    if (!mIsStarted) {
        return;
    }
    DataType dataType = dataPoint.getDataType();
    for (Field field : dataType.getFields()) {
        Value val = dataPoint.getValue(field);
        if (dataType.equals(DataType.TYPE_STEP_COUNT_DELTA)) {
            onStepTaken(val.asInt());
        } else if (dataType.equals(DataType.TYPE_SPEED)) {
            // Data comes in as meters per second, have to convert to minutes per mile.
            float speedMetersPerSeconds = val.asFloat();
            updateChallengePace(Utils.metersPerSecondToMinutesPerMile(speedMetersPerSeconds));
        }
    }
}

2. MainActivity#onDataPoint()

View license
@Override
public void onDataPoint(DataPoint dataPoint) {
    for (final Field field : dataPoint.getDataType().getFields()) {
        final Value value = dataPoint.getValue(field);
        runOnUiThread(new Runnable() {

            @Override
            public void run() {
                Toast.makeText(getApplicationContext(), "Field: " + field.getName() + " Value: " + value, Toast.LENGTH_SHORT).show();
            }
        });
    }
}