Google Fit session
Posted: 17 Aug 2016 21:06
Hello - I'm trying to start a Google Fit session automatically. I want to use an nfc tag to start "kayaking" activity.
I've been able to launch Fit using a shortcut, but I think I need to use an Intent to start the activity.
From Google API docs I found this, but I'm not sure how to use this in Automagic, and it seems like an Intent should be easier..? Thanks!
GoogleApiClient client = new GoogleApiClient.Builder(context)
.addApi(Fitness.SESSIONS_API)
...
.build();
client.connect();
Session session = new Session.Builder()
.setName(sessionName)
.setIdentifier(identifier)
.setDescription(description)
.setStartTimeMillis(startTime.getMillis(), TimeUnit.MILLISECONDS)
.build();
PendingResult<Status> pendingResult
= Fitness.SessionsApi.startSession(client, session);
I've been able to launch Fit using a shortcut, but I think I need to use an Intent to start the activity.
From Google API docs I found this, but I'm not sure how to use this in Automagic, and it seems like an Intent should be easier..? Thanks!
GoogleApiClient client = new GoogleApiClient.Builder(context)
.addApi(Fitness.SESSIONS_API)
...
.build();
client.connect();
Session session = new Session.Builder()
.setName(sessionName)
.setIdentifier(identifier)
.setDescription(description)
.setStartTimeMillis(startTime.getMillis(), TimeUnit.MILLISECONDS)
.build();
PendingResult<Status> pendingResult
= Fitness.SessionsApi.startSession(client, session);