I\'m writing an android application which needs to read user\'s fitness data (steps, calories, etc) from a back end server. this server will read the data and push notifications
In case anyone needs this, there is javadoc available here. And here is a simple example of a batch request for the user's height and weight from the backend server:
GoogleCredential credential = new GoogleCredential().setAccessToken(activeUser.getAccessToken());
Fitness fitness = new Fitness.Builder(new NetHttpTransport(),
JacksonFactory.getDefaultInstance(),
credential)
.setApplicationName("MyApp")
.build();
BatchRequest batchRequest = new BatchRequest(new NetHttpTransport(), credential);
fitness.users()
.dataSources()
.datasets()
.get("me", "derived:com.google.weight:com.google.android.gms:merge_weight",
String.format("0-%d", System.nanoTime()))
.queue(batchRequest, new WeightRequestCallback(activeUser));
fitness.users()
.dataSources()
.datasets()
.get("me", "derived:com.google.height:com.google.android.gms:merge_height",
String.format("0-%d", System.nanoTime()))
.queue(batchRequest, new HeightRequestCallback(activeUser));
batchRequest.execute();
HeightRequestCallback
and WeightRequestCallback
extend JsonBatchCallback<Dataset>