gpt4 book ai didi

android - HistoryApi.readDailyTotal() 不适用于 Wear 设备

转载 作者:行者123 更新时间:2023-11-29 00:07:08 25 4
gpt4 key购买 nike

我正在为 Android Wear 开发表盘。我想在脸上显示仅由穿戴设备记录的步骤。根据谷歌文档,这可以通过 HistoryApi.readDailyTotal() 实现。

根据文档:

The system does not require authorization to access the TYPE_STEP_COUNT_DELTA data type from the HistoryApi.readDailyTotal() method. This can be useful if you require step data for use in areas where you are unable to show the permissions panel (for example, Android Wear watch faces and activities or widget activities). For more information on how to use this data in a watch face, see Showing Information in Watch Faces.

不幸的是,这对我不起作用 - GoogleApiClient 总是返回连接失败:5 - 这意味着:客户端尝试使用指定的无效帐户名连接到服务。

这是我的客户:

mFitnessApiClient = new GoogleApiClient.Builder(MyWatchFace.this)
.addApi(Fitness.HISTORY_API)
.addScope(Fitness.SCOPE_ACTIVITY_READ)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();

知道如何解决这个问题吗?我在这方面遇到了困难。

最佳答案

我在获取可穿戴设备(仅限本地)上的总数时遇到了类似的问题,这对我有用:不要添加任何范围,并确保调用 useDefaultAccount。希望这可以帮助!例如:

mFitnessApiClient = new GoogleApiClient.Builder(MyWatchFace.this)
.addApi(Fitness.HISTORY_API)
// Do not add any scopes if using the client on the watch
.addConnectionCallbacks(this)
.useDefaultAccount() // Use the default account
.addOnConnectionFailedListener(this)
.build();

关于android - HistoryApi.readDailyTotal() 不适用于 Wear 设备,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33035757/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com