GoogleFit样品不工作 [英] GoogleFit Sample Not Working

查看:357
本文介绍了GoogleFit样品不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想的BasicHistory样品WHIS存储数据,然后读取它,但在我的情况下,code陷在插入call.await调用不返回任何东西我已经使用也异步方式尝试,这里在code

  com.google.android.gms.common.api.Status insertStatus =
Fitness.HistoryApi.insert(mClient,insertRequest).await(1,TimeUnit.MINUTES);


解决方案

你有没有要求正确的权限?

据,谷歌飞度样本,它只需要活动权限。如果您更改样品不同所使用的数据类型,请确保您的设置正确的权限。阅读谷歌飞度文件授权部分获取更多信息。

您可以添加多个权限只是增加一个新的范围,客户端:

  //创建一个谷歌API客户端
    mClient =新GoogleApiClient.Builder(本)
            .addApi(Fitness.API)
            .addScope(新范围(Scopes.FITNESS_ACTIVITY_READ_WRITE))
            .addScope(新范围(Scopes.FITNESS_BODY_READ_WRITE))
            .addScope(新范围(Scopes.FITNESS_LOCATION_READ_WRITE))
    ...

I am trying the BasicHistory Sample whis stores a data and then read it but in my case the code get stuck at the insert call.await call does not return anything i have tried using the asynchronous way also,here is the code

com.google.android.gms.common.api.Status insertStatus =
Fitness.HistoryApi.insert(mClient, insertRequest).await(1, TimeUnit.MINUTES);

解决方案

Have you requested the right permissions?

According to that Google Fit sample, it only requires permission for "Activity". If you change the data type used in that sample for other different, make sure you are setting right permissions. Read authorization section in Google Fit Doc for more information.

You can add several permissions just adding a new scope to client:

    // Create the Google API Client
    mClient = new GoogleApiClient.Builder(this)
            .addApi(Fitness.API)
            .addScope(new Scope(Scopes.FITNESS_ACTIVITY_READ_WRITE))
            .addScope(new Scope(Scopes.FITNESS_BODY_READ_WRITE))
            .addScope(new Scope(Scopes.FITNESS_LOCATION_READ_WRITE))
    ...

这篇关于GoogleFit样品不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆