Comments (39)
I fell into the same trap.
You are reading datasets from response. But according to the documentation Aggregate data is presented in buckets, while detailed data is returned as a single data set
(https://developers.google.com/android/reference/com/google/android/gms/fitness/HistoryClient.html#public-taskdatareadresponse-readdata-datareadrequest-request).
So, try to read it.buckets
instead, and you will see a data set in each bucket 👍
from fit-samples.
yooo i have the same problem. For me, the data appears fine when i have google fit installed on the device. But on the same google account on other device (which doesn't have gfit installed) all the datasets are empty
from fit-samples.
@ummesulaith in my google fit app it shows data like total step count but when i hit google fit api for getting steps counts it show empty dataset
from fit-samples.
Hi, I am using buckets, but the steps don't appear inside the buckets. Even if I remove aggregate and replace it with read(TYPE_STEP_COUNT_DELTA), Time ranges are fine. Permission exists
Solved: Apparently I didn't have Gfit installed in the device and it seems that in virtual emulator, the step sync doesn't happen even if the user has another device using which steps are tracked
from fit-samples.
yooo i have the same problem. For me, the data appears fine when i have google fit installed on the device. But on the same google account on other device (which doesn't have gfit installed) all the datasets are empty
Yup, you need gfit installed in order to get the steps from the bucket.
from fit-samples.
Yup, you need gfit installed in order to get the steps from the bucket.
Nah but you need to subscribe to google fit Recording API with the appropriate dataTypes if GFit is not installed.
from fit-samples.
How do I aggregate different Datatypes and print, for example if had to add steps and heartrate summary in the logcat, how would I do it?
from fit-samples.
Hi Folks,
I'm retrieving total steps taken by the user and active mins for the last 7 days but the fit API does not retrieve any data for few days(the days where the user had not taken any steps or if the active mins are 0). I have been trying to use the sample java code provided by the googleFit sample but I'm not sure how do I set the datapoints values as zero for the day's total steps or active mins are zero.
from fit-samples.
Hi
I am getting a response like this . Can you help.
from fit-samples.
Hi @rajatanand86,
Download google fit on mobile and link the same account whatever you are using to check on console and see what is the data u r getting 0 or any values.
from fit-samples.
Hi Done that. And its working fine. Thanks.
from fit-samples.
Hi @rajatanand86 same issue for me . can you please describe me how you solve this problem. Thanks
from fit-samples.
Download google fit on mobile and link the same account whatever you are using to check on console and see what is the data u r getting 0 or any values.
Does this help?
from fit-samples.
hi @rajatanand86 i already install google fit app in my mobile and connected the same account in my google fit app it have count but when i hit this api i get response something like this
from fit-samples.
You're getting empty dataset because you have not performed any activity. Start an walking activity and walk around with your device for 3-5 mins.
from fit-samples.
After that try to check the data on the Android studio as well as on the console
from fit-samples.
You're using java or kotlin? I can share a sample code. You can log the response
from fit-samples.
@ummesulaith xamarin forms
or hit api direct form https://developers.google.com/oauthplayground/
from fit-samples.
Ok I will check the api and share
from fit-samples.
thanks
from fit-samples.
Method: POST
URL: https://www.googleapis.com/fitness/v1/users/me/dataSources
Method : POST
URL: https://www.googleapis.com/fitness/v1/users/me/dataset:aggregate
from fit-samples.
Have you tried these ?
from fit-samples.
yes
from fit-samples.
first one is for get request and 2nd is for post
from fit-samples.
I hope for the console also you're using same account to view the data and to perform activity.
from fit-samples.
of course
from fit-samples.
can you share the response of both the API I have mentioned above with their method as post.
from fit-samples.
from fit-samples.
from fit-samples.
Okay. Where you said you're using google fit api on mobile or web site?
from fit-samples.
@ummesulaith xamarin forms
or hit api direct form https://developers.google.com/oauthplayground/
for testing purpose i use developers.google.com/oauthplayground/
from fit-samples.
Ohh okay. May be I know why are you getting the response as null. You have to request OAuth 2.0 client id. Register you're project details with SHA key and then execute the project it will show you the data. You can find the steps in fit rest api get started. As per to my knowledge I don't think so it will show you the google fit of the application data. I'm sorry that went out of my mind. Please use the sample code and then do the steps. It will help you.
from fit-samples.
i already create my project in google console or use the client id to my xamarin project. thanks anyway for help
from fit-samples.
https://github.com/googlearchive/android-fit-xamarin/blob/master/XamFit/MainActivity.cs
just use the sample code to perform some activity with the project and you should receive the data.
No Problem.
from fit-samples.
Hey guys, I have run into the same problem - valid buckets, empty data sets.
I have managed to overcome it by using deprecated methods from historical API sample:
return DataReadRequest.Builder() .aggregate(DataType.TYPE_STEP_COUNT_DELTA, DataType.AGGREGATE_STEP_COUNT_DELTA) .bucketByTime(1, TimeUnit.DAYS) .setTimeRange(startTime, endTime, TimeUnit.MILLISECONDS) .build()
Hope this will save someone's day, enjoy!
from fit-samples.
So this cannot be done using the android emulator is it?
I am running my app on the emulator, it doesn't seems to return any data point values for my steps. (I entered the step count on my phone's google fit app)
So I have to run my app on my phone instead of emulator?
from fit-samples.
@rakshahegde10 Yes you need to run it in your phone instead of the emulator to fetch datapoints and buckets
from fit-samples.
@piotrkst I'm also facing the same problem, is there an option to get data using historical API in REST APIs.
I'm working on a web application.
from fit-samples.
private fun createDataRequest(startTime: Long, endTime: Long) =
DataReadRequest.Builder()
.read(DataType.TYPE_HEART_RATE_BPM)
.enableServerQueries()
.setTimeRange(startTime, endTime, TimeUnit.MILLISECONDS)
.build()
=====
GoogleSignIn.getLastSignedInAccount(applicationContext)?.let {
Fitness.getHistoryClient(
applicationContext,
it
)
.readData(createDataRequest(startTime, endTime))
.addOnFailureListener { onError ->
Timber.e("#####---onError -- ${onError.message} -- ${onError.cause} ")
}
.addOnSuccessListener { response ->
}
I want to get data of 2 months ago, data 86400 record, data return 50023 error. but setLitmit 1000. it's okay
from fit-samples.
Related Issues (20)
- Error: I cannot use sensor client with TYPE_ACTIVITY_SEGMENT and TYPE_CALORIES_EXPENDED dataType
- I am not able to read data of Google Fit App. HOT 1
- cannot figure out what are start and end time in History API
- how to get step count for a certain date
- WearOS error 17: Error resolution was canceled by the user, original error message: INVALID_ACCOUNT: null HOT 2
- Error: Fitness api can't request data for big time intervals [E/JavaBinder: !!! FAILED BINDER TRANSACTION !!!] HOT 5
- StepCounterKotlin stuck on empty white popup after selecting Google Account HOT 30
- Read Google Fit automatically generated activities
- Find Data Source Using Sensor API HOT 1
- BMR and Calories Expended HOT 1
- After the subscription is completed, there will be a splash screen problem
- GFit steps are received on some device but some device give API exception 5000 HOT 2
- GoogelFIt gives com.google.android.gms.common.api.ApiException: 5000: Application needs OAuth consent from the user Google Fit HOT 3
- Failure: The user must be signed in to make this API call
- Issue while working with HistoryApi
- error signing into Fit HOT 2
- Google Fit Sleep
- Does Google Fit SDK work on WearOS? HOT 13
- Read heart rate data from wear os 2 watch to android app on phone
- Limit record of heart rate HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fit-samples.