當前位置: 首頁>>代碼示例>>Java>>正文


Java DataMap.getFloatArray方法代碼示例

本文整理匯總了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);
            }
        }
    }
 
開發者ID:ibm-wearables-sdk-for-mobile,項目名稱:ibm-wearables-android-sdk,代碼行數:21,代碼來源:AndroidWear.java

示例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;
}
 
開發者ID:Parrot-Developers,項目名稱:DronesWear,代碼行數:14,代碼來源:Message.java

示例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;
}
 
開發者ID:Parrot-Developers,項目名稱:DronesWear,代碼行數:14,代碼來源:Message.java

示例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();
}
 
開發者ID:Drippler,項目名稱:wearabird,代碼行數:14,代碼來源:SensorReceiverService.java

示例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);
            }
        }
    }
 
開發者ID:ibm-wearables-sdk-for-mobile,項目名稱:ibm-wearables-android-sdk,代碼行數:22,代碼來源:AndroidWear.java

示例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);
        }


    }
}
 
開發者ID:gradlman,項目名稱:SensorLib,代碼行數:57,代碼來源:SmartWatch.java


注:本文中的com.google.android.gms.wearable.DataMap.getFloatArray方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。