这让我很生气。 我有一位客户尝试在Android应用中连接到Google Fit API。 客户端之前已经被授权(并且该步骤有效)。
这是电话:
GoogleApiClient.Builder builder = new GoogleApiClient.Builder(activity.getApplicationContext())
.addApi(Fitness.SESSIONS_API)
.addApi(Fitness.SENSORS_API)
.addScope(new Scope(Scopes.FITNESS_ACTIVITY_READ_WRITE))
.addConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() {
@Override
public void onConnected(@Nullable Bundle bundle) {
LogExt.i(MyClass.class, "Connected to Google Fit....");
}
@Override
public void onConnectionSuspended(int i) {
LogExt.d(MyClass.class, "Connection to Google APIs suspended");
}
});
builder.enableAutoManage(PinCodeActivity.instance, new GoogleApiClient.OnConnectionFailedListener() {
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
if (connectionResult.isSuccess()) {
LogExt.i(MyClass.class, "Connected to Google Fit !");
} else {
LogExt.e(MyClass.class, "Cannot connect Google Fit: " + connectionResult.getErrorMessage());
}
}
});
}
gclient = builder.build();
LogExt.d(MyClass.class, "Going to connect to Google APIs...");
gclient.connect();
该应用程序然后什么都不做。没有打印日志。没有联系。没有断开连接。什么都没有。 我查看了一般日志,仍然无法找到任何线索。
在Samsung Galaxy S6,android 6.0.1上运行,导入库:com.google.android.gms:play-services-fitness:9.4.0
我输了。求救!