0

When the Android Wear app starts it sends a message to the phone and retrieves the data that is on the watch. The phone then retrieves data from the webservice and executes this method: Wearable.DataApi.putDataItem(mGoogleApiClient, putRequest.asPutDataRequest()); On the Android Wear the onDataChanged method is called. That also contains the right data. But when I restart the Android Wear app it still contains the old data and the new data hasn't been saved. I don't know what's going wrong.

This is the method for retrieving the data:

    PendingResult<DataItemBuffer> pendingResult = Wearable.DataApi.getDataItems(mGoogleApiClient, new Uri.Builder().scheme(PutDataRequest.WEAR_URI_SCHEME).path(Constants.DATA_PATH).build());
    pendingResult.setResultCallback(new ResultCallback<DataItemBuffer>()
    {
        @Override
        public void onResult(DataItemBuffer dataItems)
        {
            if (dataItems.getCount() != 0)
            {
                DataMap map = DataMapItem.fromDataItem(dataItems.get(0)).getDataMap();
                String jsonArrayString = dataMap.getString("data"); //contains old data
            }

            dataItems.release();
        }
    });
Kevin van Mierlo
  • 9,554
  • 5
  • 44
  • 76

0 Answers0