2017-09-26 15 views
0

최소, 최대 및 평균이 아닌 모든 심장 박동 측정을 받아야합니다. 이것은 내가 얻을 수있는 것입니다.Google 피트니스 기록에서 심박수 값을 가져 오는 방법은 무엇인가요?

이것은 내 Java 클래스에서 읽는 데 사용하는 코드입니다.

감사합니다.

private void readDataFitnessHistory() 
{ 
    // Setting a start and end date using a range of 1 week before this moment. 
    Calendar cal = Calendar.getInstance(); 
    Date now = new Date(); 
    cal.setTime(now); 
    long endTime = cal.getTimeInMillis(); 

    cal.add(Calendar.WEEK_OF_YEAR, -1); 
    long startTime = cal.getTimeInMillis(); 

    java.text.DateFormat dateFormat = getDateInstance(); 
    Log.d(TAG, "Range Start: " + dateFormat.format(startTime)); 
    Log.d(TAG, "Range End: " + dateFormat.format(endTime)); 

    DataReadRequest readRequest = new DataReadRequest.Builder() 
      // The data request can specify multiple data types to return, effectively 
      // combining multiple data queries into one call. 
      // In this example, it's very unlikely that the request is for several hundred 
      // datapoints each consisting of a few steps and a timestamp. The more likely 
      // scenario is wanting to see how many steps were walked per day, for 7 days. 
      .aggregate(DataType.TYPE_HEART_RATE_BPM, DataType.AGGREGATE_HEART_RATE_SUMMARY) 
      // Analogous to a "Group By" in SQL, defines how data should be aggregated. 
      // bucketByTime allows for a time span, whereas bucketBySession would allow 
      // bucketing by "sessions", which would need to be defined in code. 
      .bucketByTime(1, TimeUnit.DAYS) 
      .enableServerQueries() 
      .setTimeRange(startTime, endTime, TimeUnit.MILLISECONDS) 
      .build(); 

    // Invoke the History API to fetch the data with the query and await the result of 
    // the read request. 
    DataReadResult dataReadResult = 
      Fitness.HistoryApi.readData(mApiClient, readRequest).await(1, TimeUnit.MINUTES); 
    DataSet dataSet = dataReadResult.getDataSet(DataType.TYPE_HEART_RATE_BPM); 
    showDataSet(dataSet); 
    displayBpmDataForToday(); 


} 

응답 : 나는 내 자신의 질문에 대답하고 있습니다

History: Type: com.google.heart_rate.summary 
History: Start: 22 sept. 2017 10:40:06 
D/DBGPRUEBA History: End: 22 sept. 2017 10:40:06 
D/DBGPRUEBA History: Field: average Value: 71.13179 
D/DBGPRUEBA History: Field: max Value: 86.0 
D/DBGPRUEBA History: Field: min Value: 55.0 
+0

TYPE_HEART_RATE_BPM (분당 비트 수)은 사용자가 요구하지 않습니다. – Cadet

+0

그렇다면 표시된 시간 범위의 최소값, 최대 값 및 평균값이 아니라 표시된 시간 범위에서 모든 측정 값을 가져와야합니다. – ja12

+0

아직 가능하지 않다고 생각합니다. [documentation] (https://developers.google.com/fit/android/data-types)에 명시된 바와 같이 'com.google.heart_rate.summary' 데이터 유형을 사용하여 평균, 최대 및 최대 값을 구할 수 있습니다. 일정 시간 동안 분당 최소 박동수. – abielita

답변

0

. Google 피트니스 API를 다음과 같이 될 것이다 구축 할 수있는 객체 DataRsult로 만든 독서의 모든 데이터 포인트를 얻기 위해

:

final DataReadRequest readRequest = new DataReadRequest.Builder() 
.read(DataType.TYPE_STEP_COUNT_DELTA) 
.read(DataType.TYPE_HEART_RATE_BPM) 
.enableServerQueries() 
.setTimeRange(startTime, endTime, TimeUnit.MILLISECONDS) 
.build(); 

그것은 지정된 범위 내에서 모든 데이터 포인트를 반환합니다.