I develop a Google Fit application with Fit API for Android. I have the same google account in two devices but I can not read all the data aggregated from my application. I only read the data aggregated from the own device. I try to explain with an example:
Device A add Activity A and only read Activity A
Device B add Activity B and only read Activity B
I want to read Activity A and B in the device. I use History API for write and read the data. I try to use Recording API with subscription, add enableServerQueries, read() and aggregate() to DataReadRequest but nothing.
This is my code for read from the History API:
readRequest = new DataReadRequest.Builder()
.read(DataType.TYPE_ACTIVITY_SEGMENT).enableServerQueries()
.setTimeRange(startTime, endTime, TimeUnit.MILLISECONDS).build();
Fitness.RecordingApi.subscribe(MainActivity.mClient, DataType.TYPE_ACTIVITY_SEGMENT);
Log.i(MainActivity.TAG, "Inicializado dataRead, limite:" + d.getLimit());
DataReadResult dataReadResult = Fitness.HistoryApi.readData(MainActivity.mClient, readRequest).await(1, TimeUnit.MINUTES);
printData(dataReadResult);
Can you help me?
Thank you.
Related
I am wondering if there exists an execution id into Cloud Run as the one into Google Cloud Functions?
An ID that identifies each invocation separately, it's very useful to use the "Show matching entries" in Cloud Logging to get all logs related to an execution.
I understand the execution process is different, Cloud Run allows concurrency, but is there a workaround to assign each log to a certain execution?
My final need is to group at the same line the request and the response. Because, as for now, I am printing them separately and if a few requests arrive at the same time, I can't see what response corresponds to what request...
Thank you for your attention!
Open Telemetry looks like a great solution, but the learning and manipulation time isn't negligible,
I'm going with a custom id created in before_request, stored in Flask g and called at every print().
#app.before_request
def before_request_func():
execution_id = uuid.uuid4()
g.execution_id = execution_id
I am trying to learn how to use the ChainlinkClient and I am using their example as well as one for the API that I am trying to uses.
You can see them here on this Gist.
The two contracts in the Gist are deployed on Rinkenby here:
APIConsumner.sol
APIConsumner2.sol
When I call the requestData() method on both contracts they seems to work, the transactions goes through and Link gets taken from the contracts, I am however unable to determine whether the actual data I am requesting from the external APIs gets returned, either by looking in the transaction event or trying to access the value that I am setting.
I am a bit bamboozled at this point, any guidance or suggestions would be greatly appreciated.
Thanks for the flag. The node that was hosting this is deprecated, the article has been updated, and the docs have the latest example.
Please use:
oracle = 0xc57B33452b4F7BB189bB5AfaE9cc4aBa1f7a4FD8;
jobId = "d5270d1c311941d0b08bead21fea7747";
I am using the Forge .NET SDK. To clear all appbundles and activities under my Forge App account I call :
await _designAutomation.DeleteForgeAppAsync("me");
Right afterwards I need to (re)create a new nickname for my Forge App then (re)create the needed AppBundle and Activity :
await _designAutomation.ForgeAppsApi.CreateNicknameAsync("me", new NicknameRecord { Nickname = NICKNAME });
await EnsureAppBundle();
await EnsureActivity();
Quite often one of three calls above fails because the Forge App is still being deleted, so for instance there is a conflict for the nickname creation, or the AppBundle/Activity cannot be created.
The Forge documentation at https://forge.autodesk.com/en/docs/design-automation/v3/reference/http/forgeapps-id-DELETE/ says : This may take up to 2 minutes. During this time the app will not be able to make successful requests.
Would not the asynchronous call to DeleteForgeAppAsync have to wait for the deletion to be complete ?
Thanks for your help.
Maxime
You could handle this scenario by doing retries on 409 response following a forge app deletion.
If you want to add more logic around 409 retries you could always also inspect the body.
Per documentation here you’d need to wait a few for the delete action to take effect despite the SDK API appears to be synchronous:
This may take up to 2 minutes. During this time the app will not be able to make successful requests.
The Chromeosdevices API relies on the deviceID parameter to find devices on the back end. That has caused a bunch of confusion and frustration on my end. Initially, I thought the deviceID was the serial # of the device. We typically do all searches for device on Google's Admin console using the serial #'s, so it just made sense. I realize now that the deviceID is not the serial #.
Is there a way, then, to translate serial # to deviceId? I'm thinking I may need to export out the entire directory in some table, and then do look ups using the serial # as the reference key. But, it would be nice to figure out a programmatic way to do it. I tried searching stack overflow to no avail.
Thanks,
Figured this out. What a headache. First, if you're developing an Apps Script, there is no need to access the Admin Directory API via UrlFetchApp and trying to get it to work with Oauth2 libraries. All you need is the direct API, which I wish was illustrated in Google's API document and API explorer. Instead, use Admin SDK directly. You can create a script file with a bunch of helper functions to call from your main script:
function getDeviceId(serialnum) {
var optionalArgs = {
projection: 'BASIC',
query: serialnum,};
var chromebook = (AdminDirectory.Chromeosdevices.list("my_customer", optionalArgs)) ;
var chromebookDevID = chromebook.chromeosdevices[0].deviceId;
return chromebookDevID ;
}
For example, you call this function, pass in the serial number, and it will return the chromebook's deviceId as such
var deviceId = getDeviceId('5CD81072C4');
From this, you can also have helper functions to enable / disable chromebooks:
function disableChromeBook(deviceId) {
AdminDirectory.Chromeosdevices.action({"action": "disable"}, "my_customer", deviceId) ;
}
function enableChromeBook(deviceId) {
AdminDirectory.Chromeosdevices.action({"action": "reenable"}, "my_customer", deviceId)
}
I found the Google API document to be really obtuse. I hope this helps someone else out. Took me awhile.
I am creating application which can use google fit api.
I want to get all the activities(Movements) available in the google fit. Here the list of activities in google fit Reference.
Edited
I know the way how to get the activities which performed by user, But i want complete list of activities which available in the google fit API (Not only the activity which performed by user, need whole list of activities) like the list available in the above link.
The Google Fit activities are listed in the FitnessActivities class.
You can programmatically get a list of all these fields using:
FitnessActivities.class.getFields()
Had similar problem when started playing with Google Fit API on Android.
There are videos with code samples as well as more detailed API documentation on Google Fit website.
It helped me a lot -- https://developers.google.com/fit/android/get-started
Check both videos and later how to save and get data types:
https://developers.google.com/fit/android/data-types
To have some data available install Google Fit app on your android phone. Use it for a while and then you will have some real data in Google Fit database available.
EDIT:
If I get your edited question correctly, then you need something like the following code.
Please note that I use this in my own app that lists activities recorded by Google Fit Andorid app.
I'm not sure if it will list other activities, for example custom data types recorded by other apps.
Request "activites" (like STILL, RUNNING, WALKING) from Google Fit:
DataReadRequest readRequest = new DataReadRequest.Builder()
.read(DataType.TYPE_ACTIVITY_SEGMENT)
// maybe you want to limit data to specific time range?
//.setTimeRange(today.startTime, today.endTime, TimeUnit.MILLISECONDS)
.build();
Then parse the response. While parsing there will be activity time available:
Fitness.HistoryApi.readData(mClient, readRequest).setResultCallback(new ResultCallback<DataReadResult>() {
#Override
public void onResult(DataReadResult dataReadResult) {
for (DataSet dataSet : dataReadResult.getDataSets()) {
for (DataPoint dataPoint : dataSet.getDataPoints()) {
DataType dataType = dataPoint.getDataType();
if (dataType.equals(DataType.TYPE_ACTIVITY_SEGMENT)) {
String activity = FitnessActivities.getValue(dataPoint);
/* process as needed */
/* the `activitity' string contains values as described here:
* https://developer.android.com/reference/com/google/android/gms/fitness/FitnessActivities.html
*/
}
}
}
}
});
Like I said it works for me -- in my own app I list activities (and their type, ie. walking, running, etc) recorded by Google Fit app for Android.
Hope this can help others...
List<Session> sessions = sessionReadResponse.getSessions();
for (Session session : sessions) {
dumpSession(session);
Log.i(TAG, "Activity Name: "+sessions.get(position).getActivity());
position++;
List<DataSet> dataSets = sessionReadResponse.getDataSet(session);
for (DataSet dataSet : dataSets) {
dumpDataSet(dataSet);
}
}