Ich bin dabei, Wetterdaten von einem Android-Telefon auf eine über DataMap tragbare Android Wear zu übertragen.Konvertieren einer DataMap in eine Zeichenfolge oder ein String-Array
Ich habe es geschafft, die DataMap auf dem Gerät zu bekommen, muss aber einen Weg finden, wie es in entweder eine lange Zeichenfolge (dann in ein Array aufgeteilt) oder ein String-Array konvertieren.
Irgendwelche Ideen?
aktuelle Code am Telefon:
DataMap dataMap = new DataMap();
dataMap.putLong("1-#TIME-STAMP:", System.nanoTime());
dataMap.putLong("2-#CONTENT:", 0);
dataMap.putString("time:", currentWeather[0]);
dataMap.putString("summary:", currentWeather[1]);
dataMap.putString("icon:", currentWeather[2]);
dataMap.putString("nearestStormDistance:", currentWeather[3]);
dataMap.putString("nearestStormBEaring:", currentWeather[4]);
dataMap.putString("precipIntensity:", currentWeather[5]);
dataMap.putString("precipPRobability:", currentWeather[6]);
dataMap.putString("temperature:", currentWeather[7]);
dataMap.putString("apparentTemperature:", currentWeather[8]);
dataMap.putString("dewPoint:", currentWeather[9]);
dataMap.putString("humidity:", currentWeather[10]);
dataMap.putString("windSpeed:", currentWeather[11]);
dataMap.putString("windBearing:", currentWeather[12]);
dataMap.putString("visibility:", currentWeather[13]);
dataMap.putString("cloudCover:", currentWeather[14]);
dataMap.putString("pressure:", currentWeather[15]);
dataMap.putString("ozone:", currentWeather[16]);
new SendToDataLayerThread("/data_from_phone", dataMap).start();
aktuelle Code auf Wearable:
@Override
public void onDataChanged(DataEventBuffer dataEvents)
{
DataMap dataMap;
for (DataEvent event : dataEvents)
{
Log.v("myTag", "DataMap item: " + DataMapItem.fromDataItem(event.getDataItem()).getDataMap());
}
}