Unable to retrieve STEP_COUNT via my app from Sony Smartband2 - android

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.

Related

get step only from sensor using google fit api

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?

connecting with web server using android app & nfc tag

I want to build an android app, that when you put your phone on nfc tag, the app connect to server (I suppose database will be in web server) and get the data from database, and when you put a phone on second nfc tag it connect again to server, but this time gets diffrent data from database(must be there new database).
So basically I' am new to servers and databases and if this is posible what I mention above or at least a similar. Can you provide me with some tutorials that I can learn from and will help me build this.
Please go through the following link,
http://developer.android.com/guide/topics/connectivity/nfc/index.html
It has all the tutorials on how to utilize NFC on Android. It has certain API's available as well which you can use. The part where first it does a different operation and the next time a different one all depends on you on how you deal with it. You can write a condition based on a boolean value to see if its a first time or second.
Hope this helps.

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.

How can I get weather information to be shown on the android watchface?

I am making an Android WatchFace and would like to know how I can get weather information from the phone to the watch which I can then display on the WatchFace.
I would like to know if there are any specific APIs for the same.
Excuse me if this is a dumb question, I am new to this!
Thanks,
Shashwat
You need to obtain the weather information, using any means available to you, on the phone side and then send that data to the watch (if you want to target a specific watch) or, using DataApis, sync that data across the whole network of nodes. Then on the watch side, you need to have a component (can be part of your watch face) that can listen to changes in the data and capture the data that was received and show that in the watch face. In other words, you cannot get the weather data directly on the watch, you need to use the phone component as a proxy or so. Each of these steps can be found in the official docs (for example for data exchange see here) or among our official samples on GitHub.

How to detect nearby android devices using the same app

So basically I have made a few small apps in the past, but this is my first 'proper' app.
One of the main features of the app, and the bit that I am struggling with is that I need to be able to populate a ListView with all of the other users logged into the app, however I only want to display users that are within a set distance, for example 10 meters.
I tried using Bluetooth to achieve this, however that didn't work. I would now like to use location services to do this.
My idea is to have to app send the location of the device to an external server every few minutes and then all other devices can run a function that compare their location to others found on this server.
Does anybody know how I could go about achieving this, or know of any tutorials that cover a simpler topic. Thank you
Disclaimer: I'm not an android developer, but this seems like a design issue not a implementation issue so hopefully my comments below might be of some use...
I don't think there's an API that you can just set to "true" to get this functionality, so I think you're going to have to custom craft all the moving parts (and there are a couple). I would think the general process would be something like:
On the client:
User on client logs in to server with some sort of identity (i.e. "user#gmail.com")
Every X minutes the client app gets the current location (i.e. "100N 90E") and sends it up to a server
Every X minutes the client polls the server to see who is within 10 miles (i.e."joe#gmail.com", "mary#gmail.com")
On the server:
Needs some sort of authentication endpoints for getting a user's identity
Needs an endpoint for users to register their location ("user#gmail.com is at 100N 90E")
Needs a service to find out how far each user is from each other
Needs an endpoint to return the users within X miles (list generated from #3)
Each one of these steps shouldn't be difficult on their own and you can actually get pretty nuts with the distribution algorithm on server step #3 if you wanted to.
Some questions you can ask yourself are:
"How do I set up a server to listen for HTTP requests?" - Take a look into Node.JS for a simple solution
"How do I get a user's location in android?" - Easy google search finds plenty of documentation
"How do I write a service to continuously perform actions?" - Node.JS would again help with this
"Where will I store user's locations and their distances from each other?" - You can look into a NoSQL option like CouchBase or MongoDb. Or you could use MySQL for a more structured database.
Hope this helps...

Categories

Resources