Java Code Examples for com.google.android.gms.wearable.DataMap#putFloat()

The following examples show how to use com.google.android.gms.wearable.DataMap#putFloat() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DataManager.java    From ibm-wearables-android-sdk with Apache License 2.0 5 votes vote down vote up
/**
 * Create next data to send of the hear rate
 * @param event sensor event
 */
private void sendHeartRateData(SensorEvent event){
    PutDataMapRequest dataMapRequest = getNewSensorsDataMapRequest();

    DataMap dataMap = dataMapRequest.getDataMap();
    dataMap.putFloat("heartrate",event.values[0]);

    dataSender.sendData(dataMapRequest);
}
 
Example 2
Source File: Emmet.java    From Wear-Emmet with Apache License 2.0 4 votes vote down vote up
private void sendDataMap(String path, Object proxy, Method method, Object[] args) throws Throwable {
    final PutDataMapRequest putDataMapRequest = PutDataMapRequest.create(path);

    DataMap datamap = putDataMapRequest.getDataMap();
    datamap.putString("timestamp", new Date().toString());
    datamap.putString(METHOD_NAME, method.getName());

    {
        ArrayList<DataMap> methodDataMapList = new ArrayList<>();

        for (Object argument : args) {
            DataMap map = new DataMap();

            if (argument instanceof Integer) {
                map.putString(PARAM_TYPE, TYPE_INT);
                map.putInt(PARAM_VALUE, (Integer) argument);
            } else if (argument instanceof Float) {
                map.putString(PARAM_TYPE, TYPE_FLOAT);
                map.putFloat(PARAM_VALUE, (Float) argument);
            } else if (argument instanceof Double) {
                map.putString(PARAM_TYPE, TYPE_DOUBLE);
                map.putDouble(PARAM_VALUE, (Double) argument);
            } else if (argument instanceof Long) {
                map.putString(PARAM_TYPE, TYPE_LONG);
                map.putLong(PARAM_VALUE, (Long) argument);
            } else if (argument instanceof String) {
                map.putString(PARAM_TYPE, TYPE_STRING);
                map.putString(PARAM_VALUE, (String) argument);
            } else {
                map.putString(PARAM_TYPE, argument.getClass().getName());
                String encoded = SerialisationUtilsGSON.serialize(argument);
                map.putString(PARAM_VALUE, encoded);
            }

            methodDataMapList.add(map);
        }

        datamap.putDataMapArrayList(METHOD_PARAMS, methodDataMapList);
    }

    if (ENABLE_LOG)
        Log.d(TAG, datamap.toString());

    if (mApiClient != null) {
        if (mApiClient.isConnected()) {
            sendDataMapRequest(putDataMapRequest);
        } else {
            mWaitingDataMapItems.add(putDataMapRequest);
            mApiClient.connect();
        }
    }
}
 
Example 3
Source File: DataBundleUtil.java    From android_external_GmsLib with Apache License 2.0 4 votes vote down vote up
@Override
void store(DataMap dataMap, String key, Float value) {
    if (value != null) dataMap.putFloat(key, value);
}