简体   繁体   English

使用Google Fit API可以安装和不安装Fit App,也可以离线工作

[英]Using Google Fit API to get steps with and without Fit App installed and possible working offline

I am trying to develop an application that can count steps. 我正在尝试开发一个可以计算步数的应用程序。 I am using Xamarin.Forms, so I will have to make the Android part and the iOS part. 我正在使用Xamarin.Forms,所以我将不得不制作Android部分和iOS部分。

In the Android, I want to use Google Fit API's. 在Android中,我想使用Google Fit API。 I already implemented History API, to get the last week buckets of steps, and it is working. 我已经实现了历史API,以获得最后一周的步骤,并且它正在运行。 But this only works if the Google Fit App is installed. 但这仅适用于安装Google Fit App的情况。 But I want to have an application that is independent of Google Fit App. 但我希望有一个独立于Google Fit App的应用程序。 So, I think I need to use the Google Fit Record API or Google Fit Sensors API. 所以,我认为我需要使用Google Fit Record API或Google Fit Sensors API。 I think the Record API is automatically saving the sensor data to the History API database. 我认为Record API会自动将传感器数据保存到History API数据库。 However, to do this I will need Network access, right? 但是,要做到这一点,我需要网络访问,对吧? If yes, I would like to use it when a network is available (and GoogleFit app is not installed). 如果是,我想在网络可用时使用它(并且未安装GoogleFit应用程序)。 But when it is not available maybe the Sensors API is the right answer. 但是当它不可用时,传感器API可能是正确的答案。 Using Sensors API, should I create a Background Service (working even if the app is closed) that receive sensor data and periodically save data to a SQLite database (I already have this DB implemented)? 使用Sensors API,我是否应该创建一个后台服务(即使应用程序已关闭),它接收传感器数据并定期将数据保存到SQLite数据库(我已经实现了这个数据库)?

Am I dificulting this a lot and I just need to use one API for everything? 我是否对此进行了大量的研究,我只需要为所有内容使用一个API? I want Google Fit API because I would like to append wearables to the account when possible. 我想要Google Fit API,因为我想在可能的情况下将可穿戴设备附加到帐户中。

I really need help to understand what it is possible or not, please. 拜托,我真的需要帮助来了解它的可能性。

Thanks in advance! 提前致谢!

Android 4.4还支持两个新的复合传感器:步进检测器和步进计数器http://blog.bawa.com/2013/11/create-your-own-simple-pedometer.html或它也可以帮助您编写此代码repo https://github.com/bagilevi/android-pedometer

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM