i trying access google fit data android smartwatch service. purpose using com.google.android.gms:play-services-fitness:7.5.0 , googleapiclient connection:
mgoogleapiclient = new googleapiclient.builder(getapplicationcontext()) .addapi(fitness.history_api) .usedefaultaccount() //.setaccountname("xxxxxxxxxx@gmail.com") .addconnectioncallbacks( new googleapiclient.connectioncallbacks() { ....etc.. ....etc.. in case if use own email hardcoded in setaccountname (same account use phone , paired smartwatch), works fine. connected success , function fitness.historyapi.readdailytotal returns steps count correctly.
in case if i'm using usedefaultaccount(), connected success well, fitness.historyapi.readdailytotal returns 0 steps.
how can account name in code setacountname() method or usedefaultaccount() method properly? i'm missing here in order make work?
you can name on account using simple request per official gfit documentation.
get https://www.googleapis.com/fitness/v1/users/userid/datasources/datasourceid the datasourceid , userid 2 required parameters lead name on account.
Comments
Post a Comment