android - How do I access Google Fit user goals in Google Play Services? -


i'm showing daily user step data , activity time in android app using play services. got api setup ok , working fine, i'd read user's goals (the one's set in google fit profile) daily steps , activity time can show achieved percentage. how achieve this? cannot find of apis in com.google.android.gms.fitness.* offering this.

thanks,

michael

the latest changes in android play-services (9.8.0) supposed make possible.

1.add fitness.goals_api googleapiclient

googleapiclient = new googleapiclient.builder(crossoverwatchfaceservice.this)                 .addconnectioncallbacks([...])                 .addapi(fitness.history_api)                 .addapi(fitness.goals_api)                 .usedefaultaccount()                 .build();         googleapiclient.connect(); 

2.retrieve goal(s)

pendingresult<goalsresult> pendingresult =         fitness.goalsapi.readcurrentgoals(                 googleapiclient,                 new goalsreadrequest.builder()                         .adddatatype(datatype.type_step_count_delta)                          .build());                 pendingresult.setresultcallback(                 new resultcallbacks<goalsresult>() {                     @override                     public void onsuccess(@nonnull goalsresult goalsresult) {                         list<goal> goals = goalsresult.getgoals();                         //your code here                     }                      @override                     public void onfailure(@nonnull status status) {                         log.d(tag, "onfailure: ");                     }                 }); 

https://developers.google.com/fit/android/using-goals

and

https://developers.google.com/android/reference/com/google/android/gms/fitness/goalsapi


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -