本文整理汇总了Java中com.google.android.gms.wearable.DataMap.getFloatArray方法的典型用法代码示例。如果您正苦于以下问题:Java DataMap.getFloatArray方法的具体用法?Java DataMap.getFloatArray怎么用?Java DataMap.getFloatArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.gms.wearable.DataMap
的用法示例。
在下文中一共展示了DataMap.getFloatArray方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: triggerAccelerometerUpdate
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private void triggerAccelerometerUpdate(DataMap dataMap){
final String ACCELEROMETER_KEY = "accelerometer";
if (dataMap.containsKey(ACCELEROMETER_KEY)){
ArrayList<DataMap> accelerometerDataArrayList = dataMap.getDataMapArrayList(ACCELEROMETER_KEY);
for (DataMap accelerometerDataMap : accelerometerDataArrayList){
float[] values = accelerometerDataMap.getFloatArray("values");
AccelerometerData data = new AccelerometerData();
data.x = values[0];
data.y = values[1];
data.z = values[2];
accelerometerSensorEvents.dataEvent.trigger(data);
}
}
}
示例2: decodeAcceleroMessage
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
public static AccelerometerData decodeAcceleroMessage(DataItem dataItem) {
AccelerometerData accelerometerData = null;
if (MESSAGE_TYPE.ACC.equals(getMessageType(dataItem))) {
DataMap dataMap = DataMap.fromByteArray(dataItem.getData());
float sensordataArray[] = dataMap.getFloatArray(VALUE_STR);
if (sensordataArray != null)
{
accelerometerData = new AccelerometerData(sensordataArray[0], sensordataArray[1], sensordataArray[2]);
}
}
return accelerometerData;
}
示例3: decodeJoystickMessage
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
public static JoystickData decodeJoystickMessage(DataItem dataItem) {
JoystickData joystickData = null;
if (MESSAGE_TYPE.JOYSTICK.equals(getMessageType(dataItem))) {
DataMap dataMap = DataMap.fromByteArray(dataItem.getData());
float joystickArray[] = dataMap.getFloatArray(VALUE_STR);
if (joystickArray != null)
{
joystickData = new JoystickData(joystickArray[0], joystickArray[1]);
}
}
return joystickData;
}
示例4: unpackSensorData
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private void unpackSensorData(@SuppressWarnings("UnusedParameters") int sensorType, DataMap dataMap) {
float[] values = dataMap.getFloatArray(DataMapKeys.VALUES);
if (values.length >= 3) {
int val = (int) values[2];
if (Math.abs(val - lastSensorValue) > 1) {
remoteSensorManager.wave();
}
lastSensorValue = val;
}
remoteSensorManager.ping();
}
示例5: triggerGyroscopeUpdate
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
private void triggerGyroscopeUpdate(DataMap dataMap) {
final String GYROSCOPE_KEY = "gyroscope";
if (dataMap.containsKey(GYROSCOPE_KEY)){
ArrayList<DataMap> gyroscopeDataArrayList = dataMap.getDataMapArrayList(GYROSCOPE_KEY);
for (DataMap gyroscopeDataMap : gyroscopeDataArrayList){
float[] values = gyroscopeDataMap.getFloatArray("values");
GyroscopeData data = new GyroscopeData();
data.x = values[0];
data.y = values[1];
data.z = values[2];
gyroscopeSensorEvents.dataEvent.trigger(data);
}
}
}
示例6: unpackSensorData
import com.google.android.gms.wearable.DataMap; //导入方法依赖的package包/类
/**
* Method to extract sensor data
*
* @param dataMap map of decrypted data
*/
public void unpackSensorData(DataMap dataMap) {
if (mInternalHandler == null) {
return;
}
if (!mConnected) {
return;
}
Log.d(TAG, "unpackSensorData()");
int sensorType;
int accuracy;
int timestamp;
float[] data = dataMap.getFloatArray("sensors");
int max = (int) (data.length / mDataEntriesPerSensor);
for (int i = 0; i < max; i++) {
sensorType = (int) data[i * mDataEntriesPerSensor];
accuracy = (int) data[i * mDataEntriesPerSensor + 1];
timestamp = (int) data[i * mDataEntriesPerSensor + 2];
SmartWatchSensorDataFrame frame = new SmartWatchSensorDataFrame(this, timestamp);
if (sensorType == Sensor.TYPE_ACCELEROMETER) {
frame.ax = data[i * mDataEntriesPerSensor + 3];
frame.ay = data[i * mDataEntriesPerSensor + 4];
frame.az = data[i * mDataEntriesPerSensor + 5];
Log.i(TAG, Double.toString(frame.ax) + " " + Double.toString(frame.ay) + " " + Double.toString(frame.az) + " " + Integer.toString(timestamp));
sendNewData(frame);
}
if (sensorType == Sensor.TYPE_GYROSCOPE) {
frame.gx = data[i * mDataEntriesPerSensor + 3];
frame.gy = data[i * mDataEntriesPerSensor + 4];
frame.gz = data[i * mDataEntriesPerSensor + 5];
sendNewData(frame);
}
if (sensorType == Sensor.TYPE_MAGNETIC_FIELD) {
frame.mx = data[i * mDataEntriesPerSensor + 3];
frame.my = data[i * mDataEntriesPerSensor + 4];
frame.mz = data[i * mDataEntriesPerSensor + 5];
sendNewData(frame);
}
}
}