本文介绍了不作弊的Google Fit计步器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我对Google Fit有疑问.我正在创建一个计步器(哦, g ).到目前为止,我已经做到了,而且并不难.但是现在我们来解决我的问题.我只阅读有关Sensor API的步骤.问题是,我可以通过例如Google Fit应用程序添加新数据,该数据也将计入我的应用程序中.这会引入作弊行为,而我不希望这样做.

i have a question to Google Fit.I am creating a step counter (oh wonder g). This i have already done so far and it not really hard.But now we come to my problem. I am only reading the steps with the Sensor API. The issue is, i can add new data via for example the Google Fit app and it will be counted in my app too. This introduces cheating and i do not want this.

因此,我需要有一种方法仅读取设备创建的"数据,而不是手动添加的数据.有没有一个很好的方法来做到这一点?从SDK文档中,并不清楚如何继续执行此操作.

So i need to have a way to only read "device created" data and not manually added data. Is there a nice way to to this?From the SDK documentation it is not really clear how to proceed here.

推荐答案

我尝试了Ali Shah lakhani的建议,但

I tried as suggested by Ali Shah lakhani but

DataPoint.getOriginalDataSource().getAppPackageName();

/*I also tried but could not achieve what I wanted*/

DataPoint.getOriginalDataSource().getStreamName();
DataPoint.getOriginalDataSource().getStreamIdentifier();

在检索数据时至少对我不起作用.我最终使用了如下所示的 readDailyTotalFromLocalDevice()来捕获仅由设备捕获的步骤.

did not work at least for me while retrieving data. I ended up using readDailyTotalFromLocalDevice() as shown below in order to capture steps captured by device only.

Fitness.HistoryApi.readDailyTotalFromLocalDevice(mApiClient, DataType.TYPE_STEP_COUNT_DELTA).await(1, TimeUnit.MINUTES)

我与某些应用程序进行了交叉检查,避免在其应用程序中进行手动输入,并且上述功能提供的计数完全相同.

I cross checked the same with some of the apps that avoids manual entries in their app and the count provided by the function above is exactly the same.

注意:如果用户拥有多个设备,并且在所有设备上都使用该应用程序,则 readDailyTotalFromLocalDevice()对于每个设备都将具有不同的值,因为函数仅负责返回设备特定的数据.

Note: If a user is having multiple devices and is using the app on all of them, readDailyTotalFromLocalDevice() will have different value for each and every device since the function is responsible for returning device specific data only.

这篇关于不作弊的Google Fit计步器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 07:17