Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

# react-native-fitness
# react-native-fitness(fix crashes on Android by calling getHeartRate())
`react-native-fitness` is a library that works on both `iOS` and `Android` with it you can interact with Apple Healthkit and Google Fit.
Currently the lib provides a set of [API](#API) that you can use to read steps count or distance count for a given period of time.

Expand Down
13 changes: 7 additions & 6 deletions android/src/main/java/com/ovalmoney/fitness/manager/Manager.java
Original file line number Diff line number Diff line change
Expand Up @@ -485,13 +485,14 @@ private void processCalories(DataSet dataSet, WritableArray map) {
private void processHeartRate(DataSet dataSet, WritableArray map) {

for (DataPoint dp : dataSet.getDataPoints()) {
heartRateMap.putString("startDate", dateFormat.format(dp.getStartTime(TimeUnit.MILLISECONDS)));
heartRateMap.putString("endDate", dateFormat.format(dp.getEndTime(TimeUnit.MILLISECONDS)));
heartRateMap.putDouble("quantity", dp.getValue(dp.getDataType().getFields().get(0)).asFloat());
for(Field field : dp.getDataType().getFields()) {
WritableMap heartRateMap = Arguments.createMap();
heartRateMap.putString("startDate", dateFormat.format(dp.getStartTime(TimeUnit.MILLISECONDS)));
heartRateMap.putString("endDate", dateFormat.format(dp.getEndTime(TimeUnit.MILLISECONDS)));
heartRateMap.putDouble("quantity", dp.getValue(field).asFloat());
map.pushMap(heartRateMap);
}
heartRateMap.putDouble(field.getName(), dp.getValue(field).asFloat());
}
map.pushMap(heartRateMap);

}
}

Expand Down