Get Sleep as Android data from Google fit Using another application

2,175 views
Skip to first unread message

Maximilien Belinga

unread,
Jul 5, 2017, 7:03:43 AM7/5/17
to Sleep as Android
Hi everyone,

I'm currently working with Sleep As Android and Google Fit. Basically I want to get Sleep as Android data from Google Fit using an external application. From this: http://sleep.urbandroid.org/documentation/integration/google-fit/. It was saying that data are stored in Google Fit and any 3rd party app can view. Same as Sleep as Android can show any sleep data generated by other app.
So my question is how can I get those data, can you provide me any helpful link? I already tried to get data using basic history sessions example from google fits samples but I think I'm missing a little piece. Any help would be appreciated.


Regards,
Max.

Martin Stava

unread,
Aug 31, 2017, 7:17:06 AM8/31/17
to Sleep as Android Googlegroup, sleep-as...@googlegroups.com

Martin replied

Aug 31, 13:16
Hi,

sorry for late response. Here is code:

final SessionReadRequest.Builder sessionBuilder = new SessionReadRequest.Builder()
        .setTimeInterval(startTime, endTime, TimeUnit.MILLISECONDS)
.read(DataType.TYPE_ACTIVITY_SEGMENT)
.readSessionsFromAllApps()
.enableServerQueries();

final SessionReadRequest readRequest = sessionBuilder.build();

// Invoke the Sessions API to fetch the session with the query and wait for the result
// of the read request.
SessionReadResult sessionReadResult = SessionsApi.readSession(apiClient, readRequest).await(120, TimeUnit.SECONDS);
Status status = sessionReadResult.getStatus();


Thank you very much.

Best regards,

Martin Stava
Urbandroid Team

Did we help you? Please help us by rating our app.

Follow us: 


Sleep as Android Googlegroup sent a message

Jul 5, 13:04
--
You received this message because you are subscribed to the Google Groups "Sleep as Android" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sleep-as-an-dr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

{#HS:392015966-38807#}

Maximilien Belinga

unread,
Aug 31, 2017, 11:52:49 AM8/31/17
to sleep-as...@googlegroups.com
Thank you very much Martin, it worked like a charm. I'm going to rate the app. It's very useful.

To unsubscribe from this group and stop receiving emails from it, send an email to sleep-as-an-droid+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

{#HS:392015966-38807#}

--
You received this message because you are subscribed to a topic in the Google Groups "Sleep as Android" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sleep-as-an-droid/20HYcUTAttY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sleep-as-an-droid+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages