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

Java Value类代码示例

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

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



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

示例1: onDataPoint

import com.google.android.gms.fitness.data.Value; //导入依赖的package包/类
@Override
public void onDataPoint(DataPoint dataPoint) {
    DataType type = dataPoint.getDataType();
    Log.i(TAG, "Detected DataPoint type: " + type);

    for (final Field field : type.getFields()) {
        final Value value = dataPoint.getValue(field);
        Log.i(TAG, "Detected DataPoint field: " + field.getName());
        Log.i(TAG, "Detected DataPoint value: " + value);


   /*     activity.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                Toast.makeText(mReactContext.getApplicationContext(), "Field: " + field.getName() + " Value: " + value, Toast.LENGTH_SHORT).show();
            }
        });*/

        if(type.equals(DataType.TYPE_STEP_COUNT_CUMULATIVE)) {
            WritableMap map = Arguments.createMap();
            map.putDouble("steps", value.asInt());
            sendEvent(this.mReactContext, "StepChangedEvent", map);
        }

    }
}
 
开发者ID:StasDoskalenko,项目名称:react-native-google-fit,代码行数:27,代码来源:StepCounter.java


示例2: getView

import com.google.android.gms.fitness.data.Value; //导入依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {

    if(convertView==null){

        convertView = getLayoutInflater().inflate(R.layout.list_rows, parent, false);
    }

    StringBuilder dataValue = new StringBuilder();
    for (Field field : mDataPointList.get(position).getDataType().getFields())
    {
        Value val = mDataPointList.get(position).getValue(field);
        dataValue.append("Name: " + field.getName() + "  Value: " + val.toString());

    }

    mTextView1 = (TextView)convertView.findViewById(R.id.text1);
    mTextView1.setText("Data Type: "+ mDataPointList.get(position).getDataType().getName());
    mTextView2 = (TextView)convertView.findViewById(R.id.text2);
    mTextView2.setText(dataValue.toString());
    mTextView3 = (TextView)convertView.findViewById(R.id.text3);
    mTextView3.setText("Start Time: " + mSimpleDateFormat.format(mDataPointList.get(position).getStartTime(TimeUnit.MILLISECONDS)) +
            "\nEnd Time: " + mSimpleDateFormat.format(mDataPointList.get(position).getEndTime(TimeUnit.MILLISECONDS)));

    return convertView;
}
 
开发者ID:PacktPublishing,项目名称:Android-Sensor-Programming-By-Example,代码行数:27,代码来源:HistoryActivity.java


示例3: onDataPoint

import com.google.android.gms.fitness.data.Value; //导入依赖的package包/类
@Override
public void onDataPoint(DataPoint dataPoint) {
    final StringBuilder dataValue = new StringBuilder();
    for (Field field : dataPoint.getDataType().getFields())
    {
        Value val = dataPoint.getValue(field);
        dataValue.append("Name:" + field.getName() + "  Value:" + val.toString());
    }

    runOnUiThread(new Runnable() {
        @Override
        public void run() {
            mLiveDataText.setText(dataValue.toString());

        }
    });
}
 
开发者ID:PacktPublishing,项目名称:Android-Sensor-Programming-By-Example,代码行数:18,代码来源:SensorActivity.java


示例4: onDataPoint

import com.google.android.gms.fitness.data.Value; //导入依赖的package包/类
@Override
public void onDataPoint(DataPoint dataPoint) {
    // If we get data before the mission has started, discard them.
    if (!mIsStarted) {
        return;
    }
    DataType dataType = dataPoint.getDataType();
    for (Field field : dataType.getFields()) {
        Value val = dataPoint.getValue(field);
        if (dataType.equals(DataType.TYPE_STEP_COUNT_DELTA)) {
            onStepTaken(val.asInt());
        } else if (dataType.equals(DataType.TYPE_SPEED)) {
            // Data comes in as meters per second, have to convert to minutes per mile.
            float speedMetersPerSeconds = val.asFloat();
            updateChallengePace(Utils.metersPerSecondToMinutesPerMile(speedMetersPerSeconds));
        }
    }
}
 
开发者ID:googlesamples,项目名称:android-play-games-in-motion,代码行数:19,代码来源:Mission.java


示例5: registerFitnessDataListener

import com.google.android.gms.fitness.data.Value; //导入依赖的package包/类
/**
 * Register a listener with the Sensors API for the provided {@link DataSource} and
 * {@link DataType} combo.
 */
private void registerFitnessDataListener(DataSource dataSource, DataType dataType) {
    // [START register_data_listener]
    mListener = new OnDataPointListener() {
        @Override
        public void onDataPoint(DataPoint dataPoint) {
            for (Field field : dataPoint.getDataType().getFields()) {
                Value val = dataPoint.getValue(field);
                Log.i(TAG, "Detected DataPoint field: " + field.getName());
                Log.i(TAG, "Detected DataPoint value: " + val);
            }
        }
    };

    Fitness.SensorsApi.add(
            mClient,
            new SensorRequest.Builder()
                    .setDataSource(dataSource) // Optional but recommended for custom data sets.
                    .setDataType(dataType) // Can't be omitted.
                    .setSamplingRate(10, TimeUnit.SECONDS)
                    .build(),
            mListener)
            .setResultCallback(new ResultCallback<Status>() {
                @Override
                public void onResult(Status status) {
                    if (status.isSuccess()) {
                        Log.i(TAG, "Listener registered!");
                    } else {
                        Log.i(TAG, "Listener not registered.");
                    }
                }
            });
    // [END register_data_listener]
}
 
开发者ID:maseh87,项目名称:androidFitApp,代码行数:38,代码来源:MainActivity.java


示例6: setupSensors

import com.google.android.gms.fitness.data.Value; //导入依赖的package包/类
public void setupSensors(DataSource dataSource, DataType dataType) {
    logthis("Setup Sensors start");
    mlistener = new OnDataPointListener() {
        @Override
        public void onDataPoint(DataPoint dataPoint) {
            //we are not on the UI thread!
            for (Field field : dataPoint.getDataType().getFields()) {
                Value val = dataPoint.getValue(field);
                Log.i(TAG, "Detected DataPoint field: " + field.getName());
                sendmessage("Detected DataPoint field: " + field.getName());
                Log.i(TAG, "Detected DataPoint value: " + val);
                sendmessage("Detected DataPoint value: " + val);
            }
        }
    };

    Fitness.getSensorsClient(getActivity(), GoogleSignIn.getLastSignedInAccount(getContext()))
        .add(
            new SensorRequest.Builder()
                .setDataSource(dataSource) // Optional but recommended for custom data sets.
                .setDataType(dataType) // Can't be omitted.
                .setSamplingRate(10, TimeUnit.SECONDS)
                .build(),
            mlistener)
        .addOnCompleteListener(
            new OnCompleteListener<Void>() {
                @Override
                public void onComplete(@NonNull Task<Void> task) {
                    if (task.isSuccessful()) {
                        Log.i(TAG, "Listener registered!");
                    } else {
                        Log.e(TAG, "Listener not registered.", task.getException());
                    }
                }
            });

}
 
开发者ID:JimSeker,项目名称:googleplayAPI,代码行数:38,代码来源:SensorFragment.java


示例7: registerDataSourceListener

import com.google.android.gms.fitness.data.Value; //导入依赖的package包/类
private void registerDataSourceListener(DataType dataType) {
    onDataPointListener = new OnDataPointListener() {
        @Override
        public void onDataPoint(DataPoint dataPoint) {
            for (Field field : dataPoint.getDataType().getFields()) {
                Value aValue = dataPoint.getValue(field);
                Log.d(TAG, "registerDataSourceListener onDataPoint L-value= " + field.getName());
                Log.d(TAG, "registerDataSourceListener onDataPoint R-value=" + aValue);
                addContentToView( "dataPoint=" + field.getName() + "= " + aValue + "\n") ;



            }
        }
    };

    Fitness.SensorsApi.add(
            googleApiClient,
            new SensorRequest.Builder()
                    //  .setDataSource(dataSource)
                    .setDataType(dataType)
                    .setSamplingRate(12, TimeUnit.SECONDS)
                    .setAccuracyMode(SensorRequest.ACCURACY_MODE_DEFAULT)
                    .build(),
            onDataPointListener)
            .setResultCallback(new ResultCallback<Status>() {
                @Override
                public void onResult(Status status) {
                    if (status.isSuccess()) {
                        Log.d(TAG, "onDataPointListener  registered good");
                    } else {
                        Log.d(TAG, "onDataPointListener failed to register bad");
                    }
                }
            });

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


示例8: registerDataSourceListener

import com.google.android.gms.fitness.data.Value; //导入依赖的package包/类
private void registerDataSourceListener(DataType dataType) {
  onDataPointListener = new OnDataPointListener() {
    @Override
    public void onDataPoint(DataPoint dataPoint) {
      for (Field field : dataPoint.getDataType().getFields()) {
        Value aValue = dataPoint.getValue(field);
        Log.d(TAG, "Detected DataPoint field: " + field.getName());
        Log.d(TAG, "Detected DataPoint value: " + aValue);
        addContentToView( "dataPoint=" + field.getName() + " " + aValue + "\n") ;
      }
    }
  };

  Fitness.SensorsApi.add(
          googleApiClient,
          new SensorRequest.Builder()
        //  .setDataSource(dataSource)
          .setDataType(dataType)
          .setSamplingRate(12, TimeUnit.SECONDS)
          .setAccuracyMode(SensorRequest.ACCURACY_MODE_DEFAULT)        
          .build(),
          onDataPointListener)
          .setResultCallback(new ResultCallback<Status>() {
            @Override
            public void onResult(Status status) {
              if (status.isSuccess()) {
                Log.d(TAG, "onDataPointListener  registered good");
              } else {
                Log.d(TAG, "onDataPointListener failed to register bad");
              }
            }
          });

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


示例9: listDatasourcesAndSubscribe

import com.google.android.gms.fitness.data.Value; //导入依赖的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


示例10: subscribeToHeartRate

import com.google.android.gms.fitness.data.Value; //导入依赖的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


示例11: registerDataSourceListener

import com.google.android.gms.fitness.data.Value; //导入依赖的package包/类
private void registerDataSourceListener(DataType dataType) {

        onDataPointListener = new OnDataPointListener() {
            @Override
            public void onDataPoint(DataPoint dataPoint) {

                if (dataPoint == null) {
                    Log.d(TAG, "registerDataSourceListener onDataPoint = " + dataPoint);
                    return;
                }

                if ( dataPoint.getDataType().equals( DataType.TYPE_STEP_COUNT_CUMULATIVE) ) {
                    Log.d ( TAG, " onDataPoint of type DataType.TYPE_STEP_COUNT_CUMULATIVE " ) ;

                    for (Field field : dataPoint.getDataType().getFields()) {
                        Value aValue = dataPoint.getValue(field);
                        Log.d(TAG, "registerDataSourceListener onDataPoint L-value= " + field.getName());
                        Log.d(TAG, "registerDataSourceListener onDataPoint R-value=" + aValue);
                        addContentToView( "dataPoint=" + field.getName() + "= " + aValue + "\n") ;

                        // lets write cumulative steps
                        if ( field.getName().equals ("steps") ) {
                            // ideally one should use the same datapoint and add it to the set.
                            // rather than :-
                            DataSet originatedDataSet = originateDataSetCumulativeSteps( aValue.asInt() ) ;
                            writeQueue.add( originatedDataSet) ;
                            writeFitnessHistory();
                        }
                    }

                }


            }
        };

        Fitness.SensorsApi.add(
                googleApiClient,
                new SensorRequest.Builder()
                        //  .setDataSource(dataSource)
                        .setDataType(dataType)
                        .setSamplingRate(12, TimeUnit.SECONDS)
                        .setAccuracyMode(SensorRequest.ACCURACY_MODE_DEFAULT)
                        .build(),
                onDataPointListener)
                .setResultCallback(new ResultCallback<Status>() {
                    @Override
                    public void onResult(Status status) {
                        if (status.isSuccess()) {
                            Log.d(TAG, "onDataPointListener  registered good");
                        } else {
                            Log.d(TAG, "onDataPointListener failed to register bad");
                        }
                    }
                });

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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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