【问题标题】:Google Fit Android SDK谷歌健身 Android SDK
【发布时间】:2023-01-18 18:33:42
【问题描述】:
Scope Approved Name : .../auth/fitness.sleep.read - Not able to fetch sleep data

val client = Fitness.getSessionsClient(this, getGoogleAccount())

    val sessionReadRequest = SessionReadRequest.Builder()
            .read(DataType.TYPE_SLEEP_SEGMENT)
            .includeSleepSessions()
            .readSessionsFromAllApps()
            .setTimeInterval(periodStartMillis, periodEndMillis, TimeUnit.MILLISECONDS)
            .build()

    client.readSession(sessionReadRequest)
        .addOnSuccessListener { response ->
            for (session in response.sessions) {
                val sessionStart = session.getStartTime(TimeUnit.MILLISECONDS)
                val sessionEnd = session.getEndTime(TimeUnit.MILLISECONDS)
                Log.i(TAG, "Sleep between $sessionStart and $sessionEnd")

                // If the sleep session has finer granularity sub-components, extract them:
                val dataSets = response.getDataSet(session)
                for (dataSet in dataSets) {
                    for (point in dataSet.dataPoints) {
                        val sleepStageVal = point.getValue(Field.FIELD_SLEEP_SEGMENT_TYPE).asInt()
                        val sleepStage = SLEEP_STAGES[sleepStageVal]
                        val segmentStart = point.getStartTime(TimeUnit.MILLISECONDS)
                        val segmentEnd = point.getEndTime(TimeUnit.MILLISECONDS)
                        Log.i("TESTSLEEP", "\t* Type $sleepStage between $segmentStart and $segmentEnd")
                    }
                }
            }
        }

【问题讨论】:

  • 我需要从 Google Fit 获取当天的睡眠时间,但无法获取睡眠数据

标签: android google-fit


【解决方案1】:

心率和血压!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-10
    • 2015-01-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多