Fitness.getRecordingClient(this,GoogleSignIn.getAccountForExtension(this,fitnessOptions)).subscribe(DataType.TYPE_STEP_COUNT_CUMULATIVE).addOnSuccessListener{Log.i(TAG,"Subscription was successful!")}.addOnFailureListener{e->
Log.w(TAG,"There was a problem subscribing ",e)}
Google 健身会存储来自订阅的步数数据,即使应用未安装在 Google 健身中也是如此。
并在系统重启时恢复订阅。您的应用可以
读取每日总步数
从用户的健身历史记录中提取数据。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-07-25。"],[[["Your app can record cumulative step count data using the RecordingClient and subscribing to the `DataType.TYPE_STEP_COUNT_CUMULATIVE` data type."],["Google Fit persistently stores step data and automatically restores subscriptions, allowing your app to access daily step totals even when not actively running."],["Refer to the provided code example to learn how to implement step count recording in your application."]]],[]]