Java Code Examples for com.google.android.gms.wearable.DataMap#getFloat()
The following examples show how to use
com.google.android.gms.wearable.DataMap#getFloat() .
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: AndroidWear.java From ibm-wearables-android-sdk with Apache License 2.0 | 5 votes |
private void trigerHeartRateUpdate(DataMap dataMap) { final String HEART_RATE_KEY = "heartrate"; if (dataMap.containsKey(HEART_RATE_KEY)){ float heartRate = dataMap.getFloat(HEART_RATE_KEY); HeartRateData data = new HeartRateData(heartRate); heartRateSensorEvents.dataEvent.trigger(data); } }
Example 2
Source File: Emmet.java From Wear-Emmet with Apache License 2.0 | 4 votes |
private void callMethodOnObject(final Object object, final DataMap methodDataMap) { String methodName = methodDataMap.getString(METHOD_NAME); ArrayList<DataMap> methodDataMapList = methodDataMap.getDataMapArrayList(METHOD_PARAMS); List<Method> methodsList = getMethodWithName(object, methodName, methodDataMapList.size()); for (Method method : methodsList) { try { if (method != null) { int nbArgs = methodDataMapList.size(); Object[] params = new Object[nbArgs]; for (int argumentPos = 0; argumentPos < nbArgs; ++argumentPos) { Class paramClass = method.getParameterTypes()[argumentPos]; DataMap map = methodDataMapList.get(argumentPos); String type = map.getString(PARAM_TYPE); switch (type) { case (TYPE_INT): params[argumentPos] = map.getInt(PARAM_VALUE); break; case (TYPE_FLOAT): params[argumentPos] = map.getFloat(PARAM_VALUE); break; case (TYPE_DOUBLE): params[argumentPos] = map.getDouble(PARAM_VALUE); break; case (TYPE_LONG): params[argumentPos] = map.getLong(PARAM_VALUE); break; case (TYPE_STRING): params[argumentPos] = map.getString(PARAM_VALUE); break; default: { Type t = method.getGenericParameterTypes()[argumentPos]; Object deserialized = SerialisationUtilsGSON.deserialize(t, map.getString(PARAM_VALUE)); params[argumentPos] = deserialized; } } } //found the method method.invoke(object, params); //if call success, return / don't call other methods return; } } catch (Exception e) { Log.e(TAG, "callMethodOnObject error", e); } } }
Example 3
Source File: DataBundleUtil.java From android_external_GmsLib with Apache License 2.0 | 4 votes |
@Override Float load(DataMap dataMap, String key) { return dataMap.getFloat(key); }