7

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

3
  • The data source will probably be different. Not sure what though. Commented Jul 19, 2015 at 18:11
  • Data source will be application's package name and it will not help Commented Jul 20, 2015 at 10:18
  • 1
    Please share solution if you got it to identify user_input steps and soft step. I am getting it merged together. Commented Sep 1, 2016 at 7:51

2 Answers 2

8

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Have tried DataPoint.getOriginalDataSource().getAppPackageName() and it returns 'null'. Have also tried DataPoint.getOriginalDataSource().getStreamIdentifier() and it has some value which is not readable.
2

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.

2 Comments

Vrajesh - My issue was 3+ years old and it might possible that Google Fit APIs has been changed. I wasn't working on Google Fit API since last 2 years and so not up to date with the changes.
@Amit not an issue. I just mentioned the same in the answer so that anyone who has recently started working on the Google Fit APIs can be aware of this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.