无法从Google Fit Sensor API获取卡路里传感器API支持哪些所有数据类型?

问题描述

我没有从Sensor API获取热量。但是,传感器API会返回用于位置样本和步数的数据。

还有,有没有办法获取仍在进行的会话的实时数据?

这是我的代码

                    dataSourceRequest = new DataSourcesRequest.Builder()
                            .setDataTypes( DataType.TYPE_STEP_COUNT_CUMULATIVE)
                            .setDataTypes(DataType.TYPE_LOCATION_SAMPLE)
                            .setDataTypes(DataType.TYPE_CALORIES_EXPENDED)
                            .setDataSourceTypes(DataSource.TYPE_RAW)

                            .build();


                    Fitness.getSensorsClient(MainActivity.this,account).findDataSources(dataSourceRequest).addOnSuccessListener(MainActivity.this,new OnSuccessListener<List<DataSource>>() {
                        @Override
                        public void onSuccess(List<DataSource> dataSources) {


                            for (DataSource dataSource : dataSources) {
                                Log.e(TAG,"Data source found: " + dataSource.toString());
                                Log.e(TAG,"Data Source type: " + dataSource.getDataType().getName());

                                if(dataSource.getDataType() == DataType.TYPE_LOCATION_SAMPLE) {

                                    Log.e(TAG,"Data source for LOCATION_SAMPLE found! Registering.");
                                    registerFitnessDataListener(dataSource,DataType.TYPE_LOCATION_SAMPLE);
                                }

                                if(dataSource.getDataType() == DataType.TYPE_STEP_COUNT_CUMULATIVE) {

                                    Log.e(TAG,"Data source for STEP_SAMPLE found! Registering.");
                                    registerFitnessDataListener(dataSource,DataType.TYPE_STEP_COUNT_CUMULATIVE);
                                }

                                if(dataSource.getDataType() == DataType.TYPE_CALORIES_EXPENDED) {

                                    Log.e(TAG,"Data source for CALORIE_SAMPLE found! Registering.");
                                    registerFitnessDataListener(dataSource,DataType.TYPE_CALORIES_EXPENDED);
                                }
                            }

                            Log.e(TAG,"Sensor API Enabled " + dataSources.size());
                        }
                    }).addOnFailureListener(MainActivity.this,new OnFailureListener() {
                        @Override
                        public void onFailure(@NonNull Exception e) {

                            Log.e(TAG,"Exception- "+e);
                        }
                    });

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...