• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java DataSourcesResult类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.google.android.gms.fitness.result.DataSourcesResult的典型用法代码示例。如果您正苦于以下问题:Java DataSourcesResult类的具体用法?Java DataSourcesResult怎么用?Java DataSourcesResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DataSourcesResult类属于com.google.android.gms.fitness.result包,在下文中一共展示了DataSourcesResult类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: findFitnessDataSources

import com.google.android.gms.fitness.result.DataSourcesResult; //导入依赖的package包/类
public void findFitnessDataSources() {

        DataSourcesRequest dataSourceRequest = new DataSourcesRequest.Builder()
                .setDataTypes(DataType.TYPE_STEP_COUNT_DELTA, DataType.TYPE_STEP_COUNT_CUMULATIVE)
                .setDataSourceTypes( DataSource.TYPE_DERIVED)
                .build();

        ResultCallback<DataSourcesResult> dataSourcesResultCallback = new ResultCallback<DataSourcesResult>() {
            @Override
            public void onResult(DataSourcesResult dataSourcesResult) {
                for (DataSource dataSource : dataSourcesResult.getDataSources()) {
                    DataType type = dataSource.getDataType();

                    if (DataType.TYPE_STEP_COUNT_DELTA.equals(type)
                            || DataType.TYPE_STEP_COUNT_CUMULATIVE.equals(type)) {
                        Log.i(TAG, "Register Fitness Listener: " + type);
                        registerFitnessDataListener(dataSource, type);//DataType.TYPE_STEP_COUNT_DELTA);
                    }
                }
            }
        };

        Fitness.SensorsApi.findDataSources(googleFitManager.getGoogleApiClient(), dataSourceRequest)
                .setResultCallback(dataSourcesResultCallback);
    }
 
开发者ID:StasDoskalenko,项目名称:react-native-google-fit,代码行数:26,代码来源:StepCounter.java


示例2: listDataSources

import com.google.android.gms.fitness.result.DataSourcesResult; //导入依赖的package包/类
public void listDataSources(DataType mDataType)
{
    Fitness.SensorsApi.findDataSources(mClient, new DataSourcesRequest.Builder()
            .setDataTypes(mDataType)
            .setDataSourceTypes(DataSource.TYPE_DERIVED)
            .setDataSourceTypes(DataSource.TYPE_RAW)
            .build())
            .setResultCallback(new ResultCallback<DataSourcesResult>() {
                @Override
                public void onResult(DataSourcesResult dataSourcesResult) {
                    mListAdapter.notifyDataSetChanged();
                    if (dataSourcesResult.getDataSources().size() > 0) {
                        mDataSourceList.addAll(dataSourcesResult.getDataSources());
                        mLiveDataText.setText("Please select from following data source to get the live data");
                    } else {
                        mLiveDataText.setText("No data source found for selected data type");
                    }
                }
            });
}
 
开发者ID:PacktPublishing,项目名称:Android-Sensor-Programming-By-Example,代码行数:21,代码来源:SensorActivity.java


示例3: findFitnessDataSources

import com.google.android.gms.fitness.result.DataSourcesResult; //导入依赖的package包/类
/**
 * Find available data sources and attempt to register on a specific {@link DataType}.
 * If the application cares about a data type but doesn't care about the source of the data,
 * this can be skipped entirely, instead calling
 *     {@link com.google.android.gms.fitness.SensorsApi
 *     #register(GoogleApiClient, SensorRequest, DataSourceListener)},
 * where the {@link SensorRequest} contains the desired data type.
 */
private void findFitnessDataSources() {
    // [START find_data_sources]
    Fitness.SensorsApi.findDataSources(mClient, new DataSourcesRequest.Builder()
            // At least one datatype must be specified.
            .setDataTypes(DataType.TYPE_LOCATION_SAMPLE)
            // Can specify whether data type is raw or derived.
            .setDataSourceTypes(DataSource.TYPE_RAW)
            .build())
            .setResultCallback(new ResultCallback<DataSourcesResult>() {
                @Override
                public void onResult(DataSourcesResult dataSourcesResult) {
                    Log.i(TAG, "Result: " + dataSourcesResult.getStatus().toString());
                    for (DataSource dataSource : dataSourcesResult.getDataSources()) {
                        Log.i(TAG, "Data source found: " + dataSource.toString());
                        Log.i(TAG, "Data Source type: " + dataSource.getDataType().getName());

                        //Let's register a listener to receive Activity data!
                        if (dataSource.getDataType().equals(DataType.TYPE_LOCATION_SAMPLE)
                                && mListener == null) {
                            Log.i(TAG, "Data source for LOCATION_SAMPLE found!  Registering.");
                            registerFitnessDataListener(dataSource,
                                    DataType.TYPE_LOCATION_SAMPLE);
                        }
                    }
                }
            });
    // [END find_data_sources]
}
 
开发者ID:maseh87,项目名称:androidFitApp,代码行数:37,代码来源:MainActivity.java


示例4: findDataSources

import com.google.android.gms.fitness.result.DataSourcesResult; //导入依赖的package包/类
private void findDataSources() {


        Fitness.SensorsApi.findDataSources(googleApiClient, new DataSourcesRequest.Builder()
                .setDataTypes(DataType.TYPE_HEART_RATE_BPM)
                .setDataTypes(DataType.TYPE_SPEED)
                .setDataTypes(DataType.TYPE_STEP_COUNT_CUMULATIVE)
                .setDataSourceTypes(DataSource.TYPE_RAW)
                .build())
                .setResultCallback(new ResultCallback<DataSourcesResult>() {
                    @Override
                    public void onResult(DataSourcesResult dataSourcesResult) {
                        Log.d(TAG, "findDataSources onResult()" + dataSourcesResult.getStatus().toString() + " " + Arrays.deepToString(dataSourcesResult.getDataSources().toArray()));

                        //dataSourcesResult.getStatus().getStatusCode()

                        Log.d(TAG, "findDataSources onResult()" + dataSourcesResult.getDataSources().size());

                        for (DataSource dataSource : dataSourcesResult.getDataSources()) {
                            Log.d(TAG, "findDataSources onResult() " + dataSource);
                            Log.d(TAG, "findDataSources onResult() " + dataSource.getDataType().getName());
                            addContentToView( "dataSource=" + dataSource.getName() + "\n");

                            /*if (dataSource.getDataType().equals(DataType.TYPE_HEART_RATE_BPM)
                                    && onDataPointListener == null) {
                                Log.d(TAG, "findDataSources onResult() registering dataSource=" + dataSource);
                                registerDataSourceListener(dataSource,
                                       DataType.TYPE_HEART_RATE_BPM);

                            }*/
                        }
                    }
                });

    }
 
开发者ID:smitzey,项目名称:wearbooksource,代码行数:36,代码来源:FitWriteHistoryActivity.java


示例5: findDataSources

import com.google.android.gms.fitness.result.DataSourcesResult; //导入依赖的package包/类
private void findDataSources() {
  Fitness.SensorsApi.findDataSources(googleApiClient, new DataSourcesRequest.Builder()
          .setDataTypes(DataType.TYPE_HEART_RATE_BPM)
         // .setDataTypes(DataType.TYPE_SPEED)
         // .setDataTypes(DataType.TYPE_STEP_COUNT_CUMULATIVE)
          .setDataSourceTypes(DataSource.TYPE_RAW)
          .build())
          .setResultCallback(new ResultCallback<DataSourcesResult>() {
            @Override
            public void onResult(DataSourcesResult dataSourcesResult) {
              Log.d(TAG, "findDataSources onResult()" + dataSourcesResult.getStatus().toString());
              
              Log.d(TAG, "findDataSources onResult()" + dataSourcesResult.getDataSources().size());
              
              for (DataSource dataSource : dataSourcesResult.getDataSources()) {
                Log.d(TAG, "findDataSources onResult() " + dataSource);
                Log.d(TAG, "findDataSources onResult() " + dataSource.getDataType().getName());
                addContentToView( "dataSource DATATYPE=" + dataSource.getDataType().getName() + "\n");
                
                if (dataSource.getDataType().equals(DataType.TYPE_HEART_RATE_BPM)
                && onDataPointListener == null) {
                  Log.d(TAG, "findDataSources onResult() registering dataSource=" + dataSource);
                  registerDataSourceListener ( DataType.TYPE_HEART_RATE_BPM);
                  
                }
              }
            }
          });

}
 
开发者ID:smitzey,项目名称:wearbooksource,代码行数:31,代码来源:HelloFitActivity.java


示例6: listDatasourcesAndSubscribe

import com.google.android.gms.fitness.result.DataSourcesResult; //导入依赖的package包/类
public void listDatasourcesAndSubscribe() {
    Fitness.SensorsApi.findDataSources(client, new DataSourcesRequest.Builder()
            .setDataTypes(
                    DataType.TYPE_STEP_COUNT_DELTA,
                    DataType.TYPE_DISTANCE_DELTA)
            .setDataSourceTypes(DataSource.TYPE_DERIVED)
            .build())
            .setResultCallback(new ResultCallback<DataSourcesResult>() {
                @Override
                public void onResult(DataSourcesResult dataSourcesResult) {

                    datasources.clear();
                    listeners.clear();
                    for (DataSource dataSource : dataSourcesResult.getDataSources()) {
                        Device device = dataSource.getDevice();
                        String fields = dataSource.getDataType().getFields().toString();
                        datasources.add(device.getManufacturer() + " " + device.getModel() + " [" + dataSource.getDataType().getName() + " " + fields + "]");

                        final DataType dataType = dataSource.getDataType();
                        if (
                                dataType.equals(DataType.TYPE_STEP_COUNT_DELTA) ||
                                dataType.equals(DataType.TYPE_DISTANCE_DELTA)) {

                            final OnDataPointListener listener = new OnDataPointListener() {
                                @Override
                                public void onDataPoint(DataPoint dataPoint) {
                                    String msg = "onDataPoint: ";
                                    for (Field field : dataPoint.getDataType().getFields()) {
                                        Value value = dataPoint.getValue(field);
                                        msg += field + "=" + value + ", ";
                                    }
                                    display.show(msg);
                                }
                            };

                            Fitness.SensorsApi.add(client,
                                    new SensorRequest.Builder()
                                            .setDataSource(dataSource)
                                            .setDataType(dataType)
                                            .setSamplingRate(10, TimeUnit.SECONDS)
                                            .build(),
                                    listener)
                                    .setResultCallback(new ResultCallback<Status>() {
                                        @Override
                                        public void onResult(Status status) {
                                            if (status.isSuccess()) {
                                                listeners.add(listener);
                                                display.show("Listener for " + dataType.getName() + " registered");
                                            } else {
                                                display.show("Failed to register listener for " + dataType.getName());
                                            }
                                        }
                                    });
                        }
                    }
                    datasourcesListener.onDatasourcesListed();
                }
            });

}
 
开发者ID:parthsatra,项目名称:WalkPotato,代码行数:61,代码来源:Sensors.java


示例7: subscribeToHeartRate

import com.google.android.gms.fitness.result.DataSourcesResult; //导入依赖的package包/类
public void subscribeToHeartRate() {
    Fitness.SensorsApi.findDataSources(client, new DataSourcesRequest.Builder()
            .setDataTypes( DataType.TYPE_HEART_RATE_BPM )
            .setDataSourceTypes(DataSource.TYPE_RAW, DataSource.TYPE_DERIVED)
            .build())
            .setResultCallback(new ResultCallback<DataSourcesResult>() {
                @Override
                public void onResult(DataSourcesResult dataSourcesResult) {

                    datasources.clear();
                    listeners.clear();
                    for (DataSource dataSource : dataSourcesResult.getDataSources()) {
                        Device device = dataSource.getDevice();
                        String fields = dataSource.getDataType().getFields().toString();
                        datasources.add(device.getManufacturer() + " " + device.getModel() + " [" + dataSource.getDataType().getName() + " " + fields + "]");

                        final DataType dataType = dataSource.getDataType();
                        if (dataType.equals(DataType.TYPE_HEART_RATE_BPM)) {

                            final OnDataPointListener listener = new OnDataPointListener() {
                                @Override
                                public void onDataPoint(DataPoint dataPoint) {
                                    String msg = "onDataPoint: ";
                                    for (Field field : dataPoint.getDataType().getFields()) {
                                        Value value = dataPoint.getValue(field);
                                        msg += field + "=" + value + ", ";
                                    }
                                    display.show(msg);
                                }
                            };

                            Fitness.SensorsApi.add(client,
                                    new SensorRequest.Builder()
                                            .setDataSource(dataSource)
                                            .setDataType(dataType)
                                            .setSamplingRate(30, TimeUnit.SECONDS)
                                            .build(),
                                    listener)
                                    .setResultCallback(new ResultCallback<Status>() {
                                        @Override
                                        public void onResult(Status status) {
                                            if (status.isSuccess()) {
                                                listeners.add(listener);
                                                display.show("Listener for " + dataType.getName() + " registered");
                                            } else {
                                                display.show("Failed to register listener for " + dataType.getName());
                                            }
                                        }
                                    });
                        }
                    }
                    datasourcesListener.onDatasourcesListed();
                }
            });
}
 
开发者ID:parthsatra,项目名称:WalkPotato,代码行数:56,代码来源:Sensors.java


示例8: findDataSources

import com.google.android.gms.fitness.result.DataSourcesResult; //导入依赖的package包/类
private void findDataSources() {
    Fitness.SensorsApi.findDataSources(googleApiClient, new DataSourcesRequest.Builder()
            .setDataTypes(DataType.TYPE_HEART_RATE_BPM)
            .setDataTypes(DataType.TYPE_SPEED)
            .setDataTypes(DataType.TYPE_STEP_COUNT_CUMULATIVE)
            .setDataSourceTypes(DataSource.TYPE_RAW)
            .build())
            .setResultCallback(new ResultCallback<DataSourcesResult>() {
                @Override
                public void onResult(DataSourcesResult dataSourcesResult) {

                    String dataSourcesResultString =  Arrays.deepToString(dataSourcesResult.getDataSources().toArray()) ;
                    Log.d(TAG, "findDataSources onResult()" + dataSourcesResult.getStatus().toString() + " " +   dataSourcesResultString);

                    //dataSourcesResult.getStatus().getStatusCode()

                    addContentToView( dataSourcesResultString  ) ;

                    Log.d(TAG, "findDataSources onResult()" + dataSourcesResult.getDataSources().size());

                    for (DataSource dataSource : dataSourcesResult.getDataSources()) {
                        Log.d(TAG, "findDataSources onResult() " + dataSource);
                        Log.d(TAG, "findDataSources onResult() " + dataSource.getDataType().getName());
                        addContentToView( "dataSource=" + dataSource.getName() + "\n");

                        registerDataSourceListener(DataType.TYPE_HEART_RATE_BPM);
                        Log.d(TAG, "initGoogleApiClient() onConnected ...registerDataSourceListener TYPE_HEART_RATE_BPM");
                        registerDataSourceListener(DataType.TYPE_STEP_COUNT_CUMULATIVE);
                        Log.d(TAG, "initGoogleApiClient() onConnected ...registerDataSourceListener TYPE_STEP_COUNT_CUMULATIVE");
                        registerDataSourceListener(DataType.TYPE_SPEED);
                        registerDataSourceListener(DataType.TYPE_LOCATION_SAMPLE);
                        Log.d(TAG, "initGoogleApiClient() onConnected ...registerDataSourceListener TYPE_LOCATION_SAMPLE");



                        /*if (dataSource.getDataType().equals(DataType.TYPE_HEART_RATE_BPM)
                                && onDataPointListener == null) {
                            Log.d(TAG, "findDataSources onResult() registering dataSource=" + dataSource);
                            registerDataSourceListener(dataSource, DataType.TYPE_HEART_RATE_BPM);

                        }*/

                    }
                }
            });

}
 
开发者ID:smitzey,项目名称:wearbooksource,代码行数:48,代码来源:GHelloFitActivity.java



注:本文中的com.google.android.gms.fitness.result.DataSourcesResult类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MenuItem类代码示例发布时间:2022-05-22
下一篇:
Java ExchangeService类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap