简体   繁体   English

Android Wear上的Google Fit API问题

[英]Issue with Google Fit API on Android Wear

I'm trying to implement the Google Fit API into my android wearable application. 我正在尝试将Google Fit API实现到我的Android可穿戴应用程序中。 I have followed the GoogleFitAPI online steps with registering for an OAuth ID. 我已经按照GoogleFitAPI在线步骤注册了OAuth ID。

When trying to connect, I get an invalid account error. 尝试连接时,我收到无效的帐户错误。

Do I need to enable the free trial within the developer api console, or is there another issue that is causing this? 我是否需要在开发人员api控制台中启用免费试用,或者是否还有其他问题导致此问题?

mClient = new GoogleApiClient.Builder(this)
            .addApi(Fitness.API)
            .addScope(Fitness.SCOPE_ACTIVITY_READ)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .build();

Actually the Fit API is available on Android Wear devices. 实际上,Fit API可在Android Wear设备上使用。 But you still have to do the initial setup ( Step 5 ) one time on a paired handheld device. 但您仍需要在配对的手持设备上进行一次初始设置( 步骤5 )。 Once you've logged in and displayed the consent screen on the phone, you can access the API from the watch. 一旦您登录并在手机上显示同意屏幕,您就可以从手表访问A​​PI。 A recommendation would be to send the selected user account to the watch using the MessageAPI to avoid trying to connect to the API before the required information has been synced to the watch. 建议使用MessageAPI将所选用户帐户发送到监视,以避免在将所需信息同步到监视之前尝试连接到API。

Please note that if you chose to access the API from the watch you will ONLY get data collected by the watch (data is synced from the watch to the phone and to the cloud, but not back to the watch). 请注意,如果您选择从手表访问A​​PI,您只能获取手表收集的数据(数据将从手表同步到手机和云端,但不会返回手表)。

An alternative solution is to fetch the fitness data from the phone and send it to the watch (again using the MessageAPI). 另一种解决方案是从手机获取健身数据并将其发送到手表(再次使用MessageAPI)。

EDIT: As of Google Play Services 7.3.0 you can also use Fitness.HistoryApi.readDailyTotal() if you just want to get the daily total value. 编辑:从Google Play Services 7.3.0开始,如果您只想获取每日总价值,还可以使用Fitness.HistoryApi.readDailyTotal() This doesn't require any authentication, but will also only give you data from the local device. 这不需要任何身份验证,但也只会从本地设备提供数据。

Google Fit APIs are not yet enabled on Android Wear devices. Android Wear设备尚未启用Google Fit API。 You can connect to Google Fit on the handheld device and use the Wearable Data Layer to send data across, but obviously that uses the sensors and requires the use of a handheld device. 您可以在手持设备上连接Google Fit并使用可穿戴数据层发送数据,但显然使用传感器并需要使用手持设备。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM