華為移動服務(wù)/hms
HMS Healthkit Demo
中文 | English
目錄
簡介 開發(fā)準(zhǔn)備 環(huán)境要求 操作結(jié)果 技術(shù)支持 授權(quán)許可簡介
華為運(yùn)動健康服務(wù)(HUAWEI Health Kit)是華為提供的運(yùn)動健康能力開放服務(wù), 構(gòu)建的是一個開放的運(yùn)動健康生態(tài)數(shù)據(jù)平臺(后面統(tǒng)稱生態(tài)數(shù)據(jù)平臺)。生態(tài)數(shù)據(jù)平臺作為用戶運(yùn)動健康數(shù)據(jù)的管理者,遵循華為網(wǎng)絡(luò)安全與用戶隱私保護(hù)規(guī)范,確保用戶數(shù)據(jù)安全、完整、準(zhǔn)確。開發(fā)者通過集成華為運(yùn)動健康服務(wù),接入華為生態(tài)數(shù)據(jù)平臺。生態(tài)數(shù)據(jù)平臺提供給開發(fā)者寫入用戶運(yùn)動健康數(shù)據(jù)的接口,開發(fā)者通過調(diào)用寫入數(shù)據(jù)的接口將用戶的運(yùn)動健康數(shù)據(jù)導(dǎo)入到生態(tài)數(shù)據(jù)平臺。同時生態(tài)數(shù)據(jù)平臺提供了豐富的數(shù)據(jù)查詢接口,開發(fā)者通過調(diào)用查詢接口可以跨平臺、跨應(yīng)用獲取到用戶導(dǎo)入的運(yùn)動健康數(shù)據(jù)。生態(tài)數(shù)據(jù)平臺只對用戶授權(quán)導(dǎo)入的運(yùn)動健康數(shù)據(jù)進(jìn)行管理,并提供豐富的跨平臺、跨應(yīng)用查詢接口。
本項(xiàng)目是華為運(yùn)動健康服務(wù)的Android示例代碼,示例代碼調(diào)用了運(yùn)動健康生態(tài)數(shù)據(jù)平臺提供的Android API接口,寫入用戶的運(yùn)動健康數(shù)據(jù)和讀取用戶寫入到生態(tài)數(shù)據(jù)平臺中的數(shù)據(jù),本示例代碼只提供Android API的簡單調(diào)用,僅供參考或受限使用。
華為運(yùn)動健康服務(wù)功能如下:
登錄與授權(quán)
支持用戶登錄賬號并獲取用戶對運(yùn)動健康數(shù)據(jù)讀寫授權(quán)。
Android APIs代碼位置: appsrcmainjavacomhuaweidemohealthauthHealthKitAuthActivity.kt
取消授權(quán)
支持用戶取消賬號授權(quán)。
Android APIs代碼位置: appsrcmainjavacomhuaweidemohealthHealthKitMainActivity.kt
運(yùn)動健康數(shù)據(jù)管理
支持用戶對已授權(quán)的健康運(yùn)動數(shù)據(jù)進(jìn)行增加/刪除/更新/查詢等操作。
代碼位置: appsrcmainjavacomhuaweidemohealthHealthKitDataControllerActivity.kt
自動記錄用戶設(shè)備的步數(shù)
支持在用戶授權(quán)條件下,用戶添加對計(jì)步器的監(jiān)聽,并將傳感器中的數(shù)據(jù)以用戶已授權(quán)的運(yùn)動健康數(shù)據(jù)類型實(shí)時返回給三方。
代碼位置: appsrcmainjavacomhuaweidemohealthHealthKitAutoRecorderControllerActivity.kt
運(yùn)動記錄數(shù)據(jù)集操作
支持用戶寫入運(yùn)動包含及其全部用戶已授權(quán)的運(yùn)動健康數(shù)據(jù)集,例如一次跑步運(yùn)動包括跑步的開始時間,結(jié)束時間,以及運(yùn)動數(shù)據(jù)(軌跡, 速度, 心率)等。
支持在用戶授權(quán)條件下,用戶創(chuàng)建一個運(yùn)動(如跑步),然后開啟跑步,在跑步過程中將用戶授權(quán)的運(yùn)動健康數(shù)據(jù)寫入到生態(tài)數(shù)據(jù)平臺,最后結(jié)束運(yùn)動。
支持在用戶授權(quán)條件下,管理用戶的運(yùn)動,包括查詢,刪除,修改運(yùn)動數(shù)據(jù)等操作。
代碼位置: appsrcmainjavacomhuaweidemohealthHealthKitActivityRecordControllerActivity.kt
用戶自定義數(shù)據(jù)類型
支持在用戶授權(quán)條件下,開發(fā)可以創(chuàng)建自定義的數(shù)據(jù)類型,并使用自定義的數(shù)據(jù)類型寫入用戶的運(yùn)動健康數(shù)據(jù)到生態(tài)數(shù)據(jù)平臺。
支持用戶取消已經(jīng)添加到生態(tài)數(shù)據(jù)平臺里的監(jiān)聽器。
代碼位置: appsrcmainjavacomhuaweidemohealthHealthKitSettingControllerActivity.kt
健康記錄數(shù)據(jù)集操作
支持在用戶授權(quán)條件下,管理用戶對健康記錄數(shù)據(jù)的新增、修改、查詢操作。當(dāng)前暫時只支持心率過速、心率過緩數(shù)據(jù)類型。
代碼位置: appsrcmainjavacomhuaweidemohealthHealthKitHealthRecordControllerActivity.kt
開發(fā)準(zhǔn)備
使用Health Kit Android示例代碼前,請先檢查IDE環(huán)境是否已安裝。
解壓示例代碼包。 將代碼包拷貝到IDE目錄下,并導(dǎo)入到IDE工具中。 另外,需要生成簽名證書指紋并將證書文件添加到項(xiàng)目中,然后將配置添加到build.gradle。詳細(xì)信息(https://developer.huawei.com/consumer/cn/doc/development/HMSCore-Guides-V5/signing-fingerprint-0000001059050363-V5) 點(diǎn)擊Sync Project with Gradle Files完成開發(fā)環(huán)境構(gòu)建。使用示例代碼包中的功能之前,需要設(shè)置如下參數(shù):
華為賬號:運(yùn)動健康需要驗(yàn)證用戶是否具有讀寫健康數(shù)據(jù)的權(quán)限。 HMS SDK maven地址: 在項(xiàng)目build.gradle的allprojects->repositories中,配置HMS SDK的maven地址:maven {url 'https://developer.huawei.com/repo/' } 在項(xiàng)目build.gradle的buildscript->repositories中,配置HMS SDK的maven配置:maven {url 'https://developer.huawei.com/repo/' } 編譯依賴:在app層級的build.gradle文件中增加編譯依賴:implementation 'com.huawei.hms:health:{version}' AppId信息:在應(yīng)用的AndroidManifest.xml文件中添加在開發(fā)者聯(lián)盟創(chuàng)建應(yīng)用時生成的AppId信息。環(huán)境要求
Android Studio 3.6.1 及以上版本。 Java SDK 1.8 及以上版本。 手機(jī)Android Version7.0-13(API level 24-33),或手機(jī)系統(tǒng)為HarmonyOS;裝有HMS Core(APK)4.0.2.300及以上版本(如果需要讀取運(yùn)動健康A(chǔ)pp的數(shù)據(jù),HMS Core(APK)須為5.0.4.300及以上版本);手機(jī)裝有華為運(yùn)動健康A(chǔ)pp版本號11.0.0.512及以上。操作結(jié)果
技術(shù)支持
如果您對HMS Core還處于評估階段,可在Reddit社區(qū)獲取關(guān)于HMS Core的最新訊息,并與其他開發(fā)者交流見解。
如果您對使用HMS示例代碼有疑問,請嘗試:
開發(fā)過程遇到問題上Stack Overflow,在huawei-mobile-services 標(biāo)簽下提問,有華為研發(fā)專家在線一對一解決您的問題。 到華為開發(fā)者論壇 HMS Core板塊與其他開發(fā)者進(jìn)行交流。如果您在嘗試示例代碼中遇到問題,請向倉庫提交issue,也歡迎您提交Pull Request。
授權(quán)許可
華為運(yùn)動健康服務(wù)示例代碼經(jīng)過 Apache License 2.0授權(quán)許可。
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: You must give any other recipients of the Work or Derivative Works a copy of this License; and You must cause any modified files to carry prominent notices stating that You changed the files; and You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS
相關(guān)知識
運(yùn)動健康服務(wù)
華為運(yùn)動健康A(chǔ)pp微體檢報告解讀服務(wù)
健康醫(yī)療行業(yè)移動醫(yī)療服務(wù)平臺建設(shè)方案.doc
移動醫(yī)療:體驗(yàn)醫(yī)療服務(wù)信息化
移動健康管理APP的服務(wù)功能分析
華為運(yùn)動健康只能綁定華為設(shè)備嗎?
移動藥房為移動醫(yī)療注入活力
華為運(yùn)動健康A(chǔ)pp家庭空間
華為擎云亮相健康服務(wù)業(yè)大會 全新商用穿戴推動健康服務(wù)業(yè)進(jìn)入新高度
醫(yī)療服務(wù)方式投資分析 移動醫(yī)療投資機(jī)會全息圖
網(wǎng)址: 華為移動服務(wù)/hms http://www.u1s5d6.cn/newsview205242.html
推薦資訊
- 1發(fā)朋友圈對老公徹底失望的心情 12775
- 2BMI體重指數(shù)計(jì)算公式是什么 11235
- 3補(bǔ)腎吃什么 補(bǔ)腎最佳食物推薦 11199
- 4性生活姿勢有哪些 盤點(diǎn)夫妻性 10425
- 5BMI正常值范圍一般是多少? 10137
- 6在線基礎(chǔ)代謝率(BMR)計(jì)算 9652
- 7一邊做飯一邊躁狂怎么辦 9138
- 8從出汗看健康 出汗透露你的健 9063
- 9早上怎么喝水最健康? 8613
- 10五大原因危害女性健康 如何保 7826