We are working on an Android application which queries Google Fit API to retrieve Steps, Calories and Distance parameter. We want to query activities which are NOT manually entered by user (or somehow identify these kind of activity and ignore them).
User's can manually load Walking, Running etc activity, and we want to ignore such activities. We looked into History APIs and Activity Fields, but it seems there is no way to identify whether activities are manually logged or automatically added by other apps OR phone sensors OR wearable devices.
Can someone knows a way to get activities which are not manually logged by user?
UPDATE
Check below thread on Google Fit Developer Community, it may help someone
https://plus.google.com/u/0/105650643673857572241/posts/fET6zKYFq4K
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.
来源:https://stackoverflow.com/questions/31451851/how-to-identify-google-fit-activity-is-entered-manually-or-tracked-by-sensor