How to identify google fit activity is entered manually or tracked by sensor?

本小妞迷上赌 提交于 2019-11-30 20:34:35

This may not be the correct way to identify sensor detected steps, but with some testing, it almost matches steps which I think recorded by sensor.

DataSource ds = DataPoint.getOriginalDataSource()

String dataStream = ds.getStreamIdentifier()

If "dataStream" string contains soft_step_delta, then we can assume that steps are recorded from phone sensor. I haven't tested it with wearable device.

I tried as suggested by Amit above but

DataPoint.getOriginalDataSource().getStreamIdentifier();

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

DataPoint.getOriginalDataSource().getStreamName();
DataPoint.getOriginalDataSource().getAppPackageName();

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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!