diff --git a/android/src/main/java/de/perfood/capacitorgooglefit/GoogleFitPlugin.java b/android/src/main/java/de/perfood/capacitorgooglefit/GoogleFitPlugin.java index 98e2e0f..b27e4f5 100644 --- a/android/src/main/java/de/perfood/capacitorgooglefit/GoogleFitPlugin.java +++ b/android/src/main/java/de/perfood/capacitorgooglefit/GoogleFitPlugin.java @@ -174,16 +174,18 @@ public Task getSteps(final PluginCall call) throws ParseExcept public void onSuccess(DataReadResponse dataReadResponse) { List buckets = dataReadResponse.getBuckets(); - JSONObject steps = new JSONObject(); + JSONArray steps = new JSONArray(); for (Bucket bucket : buckets) { for (DataSet dataSet : bucket.getDataSets()) { for (DataPoint dp : dataSet.getDataPoints()) { for (Field field : dp.getDataType().getFields()) { + JSONObject stepEntry = new JSONObject(); try { - steps.put("startTime", timestampToDate(dp.getStartTime(TimeUnit.MILLISECONDS))); - steps.put("endTime", timestampToDate(dp.getEndTime(TimeUnit.MILLISECONDS))); - steps.put("value", dp.getValue(field).toString()); + stepEntry.put("startTime", timestampToDate(dp.getStartTime(TimeUnit.MILLISECONDS))); + stepEntry.put("endTime", timestampToDate(dp.getEndTime(TimeUnit.MILLISECONDS))); + stepEntry.put("value", dp.getValue(field).toString()); + steps.put(stepEntry); } catch (JSONException e) { call.reject(e.getMessage()); return; @@ -194,7 +196,6 @@ public void onSuccess(DataReadResponse dataReadResponse) { } JSObject result = new JSObject(); - result.put("steps", steps); call.resolve(result);