get step only from sensor using google fit api - android

I want to get step value using google fit api and tried the example provided by google here. I could successfully implemented it and am able to retrieve history data (both today data and past data).
However, if I insert step value (from insert activity) manually to fit app, or integrated third party apps to the fit app, it will take all the step value (it will get the same value as what fit app shows).
I don't want the step value from user input neither from the third app.
Is it possible to separate the step value based on the data source if we use fit API.
*in fit FAQ page , it is written:
How do I query for available third-party or other data sources?
Today, this is only available via the REST API; this data is not yet available via the Android API.
so does it mean, we can not query the data from the sensor only?

Related

updateData() vs insertData() in Google Fit

I'm building an Android app which syncs data to Google Fit and uses the Google Fit SDK to achieve that - but I'm pretty sure my question also applies when you are using the REST API.
Within my app users can also change data inserted to Google Fit. The Google Fit SDK has two distinct functions to handle those kind of things: insertData() and updateData().
Now, I don't want to keep track of whether a user changed an already synced data point vs whether it is an entirely new datapoint. I just want to have a simple Boolean flag which indicates whether a data point has already been uploaded to Google Fit or not - that's to keep things simple and reliable on the app's side.
So when a user creates a new data point in my app, I set a syncedToGoogleFit flag for that data point in my DB to 0. When the data point has been synced to Google Fit I set it to 1. When the user later changes the data point in my app I set it to 0 again and so on.
However, the Google Fit SDK distinguishes between inserting and updating which means a simple Boolean wouldn't be enough to track changes on my end as insertData() will fail if there already is a data point for a given timestamp. Is it possible to always call updateData() even if I am actually inserting new data and that way get by with just the Boolean flag on my end?
Looking at the documentation it should be okay, but I would feel safer if someone could confirm that. Also I'd like to know whether there are any potential performance implications of the approach outlined above, but I guess this is just something the SDK devs can answer.
I've played around quite a bit with the SDK now and from what I am seeing I can say, that using updateData() seems to work just fine.

Unable to retrieve STEP_COUNT via my app from Sony Smartband2

This is not a repeated question as all other questions either refer to the REST Api or retrieve step count from the device (usually the phone) on which the app is running. It is also different from android wear questions, as no separate app can be built for the Smartband2.
I want to retrieve the heart rate and the step count. I am successfully able to get the heart-rate via the BLE Api
However, for the step-count I've been having a lot of trouble.
I understand that the best way to get the step-count is through Google Fit APIs.
I tried using the Sensor Api, but only my phone on which the app is running gets listed as a Data Source.
On using the Google fit BLE Api ,the band gets detected only when I search for TYPE_HEART_RATE_BPM, but not when TYPE_STEP_COUNT_CUMULATIVE or TYPE_STEP_COUNT_DELTA
From the comment by noogui here, I understand I'll have to use the Recording and History Api.
On the other hand, there's an option to create Additional Sensorfrom similar questions posted earlier.
I'm utterly confused as how to go about this now.
TLDR: Could someone please list out the steps and the APIs I will need to get step-count data from Smartband2? An example would be very helpful.
The SmartBand2 matches step data against the step counter in the phone to provide a more accurate reading, and because of that you can't get step delta or cadence from the Sensors API. You can either try using the LifeLog SDK (which I haven't tried but it looked like you could use it for semi live sensor data) or grab step data from the History API.
And before you complain about not getting live data let me just say I'm working with a bunch of test units from different makers and the SmartBand 2 has the cleanest and most accurate data stream of any of them. The lack of live step count is a pain but most bands don't deliver that anyway, and the ones that do that I know about have turned out to be overpriced garbage in every other respect.
I was able to get the heart-rate and step-count data using the following method:
Pair the Smartband2 with the official Sony Smartband2 app.
In the app: settings -> Google fit -> Turn on
Write an app that uses the History api from Google Fit. Example: https://github.com/googlesamples/android-fit/tree/master/BasicHistoryApi
Fetch data for every minute for last ten minutes for Heart-rate and step-count
No Ble api or other additional raw sensor creation was required.

Is it possible to add custom parameters to Firebase Dynamic Links?

So I'm developing a game for Android and I'm using Firebase for Authentication, to store user data, etc...
And now, I want to provide the user a way to share their score with their friends, so they can try to beat that score. I was thinking about sharing a dynamic link, and when the second user gets the link, the game would just start from that checkpoint.
But to do that, I would need to send a few data: the level Number, the first user's score, the first user's name.
I checked the documentation here and I saw that I can add some custom campaign parameters. But can I add those other parameters I need? If yes, How do I do it?
build Uri :
builder.scheme("https").authority("deepLink_from_firebase").appendQueryParameter("Param", Param_value).build();
and set that on setDeepLink()
To do this with Firebase, you would need to either encode all the custom data in the URL, or store it in your backend and use the URL as a key to retrieve the stored values. It's possible, but not as intuitive as you're hoping.
I would recommend investigating Branch.io (full disclosure: I am on the Branch team). The Branch service is free, does store an unlimited number of custom parameters with each link (exactly as you described), and interfaces perfectly with the other Firebase functions you are currently using. Branch links are used for this by many of the top apps in the world, including Airbnb, Pinterest, Tinder, and many others.

Google Fit Custom Data Type

I am creating one Google Fit compatible App. My objective is to store Google Fit data using HistoryApi, and provide kind of Back Up- Restore functionality to user. If user buys new Android devices then he/she should be able to BackUp(sync) old data using his/her account.
I need to use Custom Data Type, as Public Data Types doesn't meet my requirements.
Everything works perfect, I am able to insert data and read data using History Api.
But When I try to read data from Another Android device using same Google Account then data is not available to read there.
My problem seems similar to this Custom DataTypes not synching between devices
This statement from Google Fit Document is not clear to me.
Custom data types are not available to use in other apps. Only the app
that creates a custom fitness data type can use it
source : CustomDataType
Q-1) What does it really means ? If I have an app GoogleFitDemo installed on multiple Android devices, then is it possible to sync data between this same app between multiple Android devices ?
Q-2)Is it improper way to store and backup data using Google fit ?
Update:
Finally, I found that Custom Data Type can also be synced normally, same as other Public Data Types. I had the sync issue as mentioned by #Ifor. Sync functionality is still buggy. In some scenarios sync stops working, and sometimes synced data is inconsistent across multiple devices.
1). My understanding is that same app same account but different devices it should work. Having said that sync is notoriously slow (hours days...) and has been buggy so it may be hard to tell if you have it right or not.
2) There are better backup methods... But if the data fits in with the rest of the stuff Google Fit is about and is not too big then it's probably ok.

Manual Data flag in Google Fit Android API?

Does the Google Fit API provide any flag to indicate the data was entered manually in the app.If yes, please suggest which needs to checked for that as the requirement is to process only the device collected data and not the manual entries in fitness apps.
Closest you can get to achieve is this to filter out the results provided by the google fit sdk based on the original data source attributes.
For example
dataset.dataPoints.forEach {
it.originalDataSource.appPackageName
it.originalDataSource.device
it.originalDataSource.name
}

Categories

Resources