- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试将 hydration 数据插入Google Fit。但是我无法插入数据。
这是我的代码:
BuildFitnessClient:
private void buildFitnessClient() {
Log.w("Fit","inside buildFitness");
// Create the Google API Client
if (mClient == null) {
mClient = new GoogleApiClient.Builder(this)
.addApi(Fitness.HISTORY_API)
.addApi(Fitness.SESSIONS_API)
//.addScope(new Scope(Scopes.FITNESS_LOCATION_READ_WRITE))
.addScope(new Scope(Scopes.FITNESS_ACTIVITY_READ_WRITE))
.addConnectionCallbacks(
new GoogleApiClient.ConnectionCallbacks() {
@Override
public void onConnected(Bundle bundle) {
Log.i(TAG, "Connected!!!");
// Now you can make calls to the Fitness APIs. What to do?
// Play with some sessions!!
new InsertAndVerifyDataTask().execute();
}
@Override
public void onConnectionSuspended(int i) {
// If your connection to the sensor gets lost at some point,
// you'll be able to determine the reason and react to it here.
if (i == GoogleApiClient.ConnectionCallbacks.CAUSE_NETWORK_LOST) {
Log.i(TAG, "Connection lost. Cause: Network Lost.");
} else if (i
== GoogleApiClient.ConnectionCallbacks.CAUSE_SERVICE_DISCONNECTED) {
Log.i(TAG,
"Connection lost. Reason: Service Disconnected");
}
}
}
)
.enableAutoManage(this, 0, new GoogleApiClient.OnConnectionFailedListener() {
@Override
public void onConnectionFailed(ConnectionResult result) {
Log.i(TAG, "Google Play services connection failed. Cause: " +
result.toString());
Snackbar.make(
DeviceControlActivity.this.findViewById(R.id.gatt_services),
"Exception while connecting to Google Play services: " +
result.getErrorMessage(),
Snackbar.LENGTH_INDEFINITE).show();
}
})
.build();
}
}
private class InsertAndVerifyDataTask extends AsyncTask<Void, Void, Void> {
protected Void doInBackground(Void... params) {
// Create a new dataset and insertion request.
DataSet dataSet = insertFitnessData();
// [START insert_dataset]
// Then, invoke the History API to insert the data and await the result, which is
// possible here because of the {@link AsyncTask}. Always include a timeout when calling
// await() to prevent hanging that can occur from the service being shutdown because
// of low memory or other conditions.
Log.i(TAG, "Inserting the dataset in the History API.");
Log.w("Fit", "Inserting the dataset in the HISTORY api");
com.google.android.gms.common.api.Status insertStatus =
Fitness.HistoryApi.insertData(mClient, dataSet)
.await(1, TimeUnit.MINUTES);
// Before querying the data, check to see if the insertion succeeded.
if (!insertStatus.isSuccess()) {
Log.i(TAG, "There was a problem inserting the dataset.");
Log.w("Fit", "Error inserting data");
return null;
}
// At this point, the data has been inserted and can be read.
Log.i(TAG, "Data insert was successful!");
// [END insert_dataset]
// Begin by creating the query.
// DataReadRequest readRequest = queryFitnessData();
// [START read_dataset]
// Invoke the History API to fetch the data with the query and await the result of
// the read request.
// DataReadResult dataReadResult =
// Fitness.HistoryApi.readData(mClient, readRequest).await(1, TimeUnit.MINUTES);
// [END read_dataset]
// For the sake of the sample, we'll print the data so we can see what we just added.
// In general, logging fitness information should be avoided for privacy reasons.
// printData(dataReadResult);
return null;
}
}
private DataSet insertFitnessData() {
Log.i(TAG, "Creating a new data insert request.");
// [START build_insert_data_request]
// Set a start and end time for our data, using a start time of 1 hour before this moment.
Calendar cal = Calendar.getInstance();
Date now = new Date();
cal.setTime(now);
long endTime = cal.getTimeInMillis();
cal.add(Calendar.HOUR_OF_DAY, -1);
long startTime = cal.getTimeInMillis();
// Create a data source
DataSource dataSource = new DataSource.Builder()
.setAppPackageName(this)
.setDataType(DataType.TYPE_HYDRATION)
.setStreamName(TAG + " - waterConsumed")
.setType(DataSource.TYPE_RAW)
.build();
// Create a data set
float waterConsumed = 0.3f;
DataSet dataSet = DataSet.create(dataSource);
// For each data point, specify a start time, end time, and the data value -- in this case,
// the number of new steps.
DataPoint hydration = DataPoint.create(dataSource);
hydration.setTimestamp(cal.getTimeInMillis(), TimeUnit.MILLISECONDS);
hydration.getValue(Field.FIELD_VOLUME).setFloat(waterConsumed);
dataSet.add(hydration);
// [END build_insert_data_request]
return dataSet;
}
06-30 00:09:21.416 10294-10294/com.polkapolka.bluetooth.le I/DeviceControlActivity: Connected!!!
06-30 00:09:21.422 10294-12719/com.polkapolka.bluetooth.le I/DeviceControlActivity: Creating a new data insert request.
06-30 00:09:21.457 10294-12719/com.polkapolka.bluetooth.le I/DeviceControlActivity: Inserting the dataset in the History API.
06-30 00:09:21.457 10294-12719/com.polkapolka.bluetooth.le W/Fit: Inserting the dataset in the HISTORY api
06-30 00:09:22.929 10294-12719/com.polkapolka.bluetooth.le I/DeviceControlActivity: There was a problem inserting the dataset.
06-30 00:09:22.929 10294-12719/com.polkapolka.bluetooth.le W/Fit: Error inserting data
06-30 00:09:40.164 10294-10294/com.polkapolka.bluetooth.le D/ViewRootImpl: doProcessInputEvents ViewRoot{81b6602 com.polkapolka.bluetooth.le/com.polkapolka.bluetooth.le.DeviceControlActivity,ident = 1}
06-30 00:09:40.164 10294-10294/com.polkapolka.bluetooth.le D/View: Touch up dispatch to android.widget.Button{f043f11 VFED..C.. ...P.... 453,0-645,144 #7f0c0091 app:id/btn_fit}, event = MotionEvent { action=ACTION_UP, actionButton=0, id[0]=0, x[0]=40.51526, y[0]=64.24573, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=150185425, downTime=150185381, deviceId=3, source=0x1002 }
06-30 00:09:40.164 10294-10294/com.polkapolka.bluetooth.le D/SettingsInterface: from settings cache , name = sound_effects_enabled , value = 1
06-30 00:09:40.164 10294-10294/com.polkapolka.bluetooth.le W/Fit: calling buildFitness
06-30 00:09:40.164 10294-10294/com.polkapolka.bluetooth.le W/Fit: inside buildFitness
06-30 00:10:13.225 10294-10294/com.polkapolka.bluetooth.le D/ViewRootImpl: doProcessInputEvents ViewRoot{81b6602 com.polkapolka.bluetooth.le/com.polkapolka.bluetooth.le.DeviceControlActivity,ident = 1}
06-30 00:10:13.225 10294-10294/com.polkapolka.bluetooth.le D/View: Touch up dispatch to android.widget.Button{f043f11 VFED..C.. ...P.... 453,0-645,144 #7f0c0091 app:id/btn_fit}, event = MotionEvent { action=ACTION_UP, actionButton=0, id[0]=0, x[0]=89.46991, y[0]=74.24048, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=150218486, downTime=150218460, deviceId=3, source=0x1002 }
06-30 00:10:13.226 10294-10294/com.polkapolka.bluetooth.le D/SettingsInterface: from settings cache , name = sound_effects_enabled , value = 1
06-30 00:10:13.226 10294-10294/com.polkapolka.bluetooth.le W/Fit: calling buildFitness
06-30 00:10:13.226 10294-10294/com.polkapolka.bluetooth.le W/Fit: inside buildFitness
06-30 00:20:03.346 10294-10294/com.polkapolka.bluetooth.le V/InputMethodManager: START INPUT: android.widget.NumberPicker$CustomEditText{1734323 VFED..CL. .F...... 0,38-192,111 #102038b android:id/numberpicker_input} ic=com.android.internal.widget.EditableInputConnection@347dd7a tba=android.view.inputmethod.EditorInfo@170a92b controlFlags=#100
06-30 00:20:03.378 10294-10294/com.polkapolka.bluetooth.le I/Activity: [AppLaunch] activity.onPause +
06-30 00:20:03.413 10294-10294/com.polkapolka.bluetooth.le I/Activity: [AppLaunch] activity.onPause -
最佳答案
确保已在new Scope(Scopes.FITNESS_NUTRITION_READ_WRITE)
的requestScopes
中添加了 GoogleSignInOptions.Builder
。数据类型TYPE_HYDRATION
属于范围FITNESS_NUTRITION。该应用程序还需要卸载并重新安装,以将新范围添加到该帐户。您可以检查此link。
关于android - 无法将 hydration 数据插入Google Fit,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44833100/
如果没有 Google Fit 应用程序,是否可以使用 Google Fit API? 我想使用 Google Fit API 来计算步数,但是可以在不安装 Google Fit 应用程序的情况下完成
我的应用程序中实现的代码曾经有效,数据已正确插入/显示在 Google Fit 中,但现在不起作用。 我还测试了 BasicHistoryApi 但它不起作用。( https://github.com
我正在努力显示与 Google Fit 应用程序相同的 Activity 历史记录。我在 session 方面做得很好,但我无法正确掌握自动记录的 Activity 。就像示例中的这两个顶级行走一样。
我在使用 Google Fit Api 获取行进距离时遇到问题。我对计步器使用了类似的方法并且有效。它只是说听众已注册。 大部分代码来自 Github 示例。 有什么问题吗? public class
我正在使用此代码尝试检索过去 14 小时内执行的步骤。 YApp myApp = (mYApp) ctx; mGoogleApiClient = myApp.getMyUser();
使用 google fit api 时是否有配额和请求限制?我想使用 google fit api,我很好奇使用它时是否有限制。 最佳答案 您可以在 Google Developer Console
使用 google fit api 时是否有配额和请求限制?我想使用 google fit api,我很好奇使用它时是否有限制。 最佳答案 您可以在 Google Developer Console
无论是使用 fit$loadings 还是使用 fit$Vaccounted 检查它们,我都得到不同的方差值,这些值由因子分析中的因子解释。我正在使用带有 fa() 函数的 psych 包。如果它们应
如果我进入 google api Playground,我会执行以下步骤: 第 1 步:选择并授权 API。我选择两个范围 https://www.googleapis.com/auth/fitnes
我正在执行 https://developers.google.com/fit/android/get-started 中提到的步骤实现一个简单的健身 Android 应用程序。 但是当我想这样做的时
在过去的 6 个月里,我一直在将我的体重输入 Google Fit,现在我想把我的数据拿出来。 访问 Google Fit REST API 不是问题。然而,在所有可访问的数据中找到我的体重数据让我很
我最近尝试尝试使用 Google Fit 应用程序并尝试了 Google Fit developer site 中给出的步骤.并使用了 Android 示例中给出的代码 BasicSensorApi在
我正在创建可以使用 google fit api 的应用程序。 我想获得 google fit 中可用的所有事件( Action )。这里是 google fit 中的事件列表 Reference 。
我尝试了随机森林回归。 代码如下。 import numpy as np from sklearn.preprocessing import StandardScaler from sklearn.m
Google Play documentation claims this is an API_NOT_CONNECTED code ,但是为了访问 Google Fit API,我已经完成了我(认为
我正在使用google javascript api 。为了获取卡路里,我正在使用下一个数据源: 派生:com.google.calories.expished:com.google.android.
我开发了一个需要显示每日步数的应用程序。为此,我使用了 Google Fit SDK 中提供的 API。 似乎一切正常,但我得到的步数与 Google Fit 官方应用程序中显示的步数不匹配。 例如,
我正在尝试从 google fit API 检索用户的每周步数数据,但我从官方 google fit App 数据中获得了不同的步数结果。例如:星期四通过 google fit api 检索到的步数是
我们已经在我们的用户群中发现,自上次 google fit 应用程序更新以来,数据急剧下降,自开始以来,我们一直试图找出代码中的问题。给出时间,我们认为我们使用的版本(当时是 18.0)是问题所在。
拟合高斯混合模型(X-Y数据集)后,如何获取每个分布的参数?例如每个分布的均值、标准差、权重和角度? 我想我可以找到代码 here : def make_ellipses(gmm, ax):
我是一名优秀的程序员,十分优秀!