1

I am developing demo application for wear and handheld. When wear starts it sends request to handheld and get list along with time stamp. and while we click on any list item, it sends changes to handheld again. This works perfectly

But not i want to sends list while on click of device list is performs. in device activity thread

       class SendToDataLayerThread extends Thread {

    String path;
    DataMap dataMap;

    SendToDataLayerThread(String p,DataMap d){
        path = p;
        dataMap = d;
    }

    @Override
    public void run() {

         PutDataMapRequest putDMR= PutDataMapRequest.create(path);
                ArrayList<Job> arrlist=new ArrayList<>();
                ArrayList<String> staticArray=new ArrayList<>();
                mydb=new DBHelper(ListOfTaskActivity.this);
                arrlist.clear();
                arrlist = mydb.getAllCalls();

                if(arrlist.size()>0) {
                    for (int i = 0; i < arrlist.size(); i++) {
                        staticArray.add(arrlist.get(i).get_id()+"~"+arrlist.get(i).getJob_status()+"~"+arrlist.get(i).getJob_placename());

                    }
                }

                dataMap.putStringArrayList("CallArrayList", staticArray);

            NodeApi.GetConnectedNodesResult nodes = Wearable.NodeApi.getConnectedNodes(wagoogleApiClient).await();
            for(Node node : nodes.getNodes()) {
                if(wagoogleApiClient.isConnected()){

                    dataMap.putLong("new_TimeStamp", new Date().getTime());
                    putDMR.getDataMap().putAll(dataMap);

                    PutDataRequest request = putDMR.asPutDataRequest();
                    Wearable.DataApi.putDataItem(googleApiClient,request);
                }
            }
       }
  }

this works, but wearable service onDataChanged never called

wear service

   public class WearableService extends WearableListenerService {
         @Override
public void onDataChanged(DataEventBuffer dataEvents) {
    super.onDataChanged(dataEvents);
     DataMap dataMap;
    try {
        for (DataEvent event : dataEvents) {
            Log.d(TAG, "in for DataEvent event : dataEvents");
            if (event.getType() == DataEvent.TYPE_CHANGED) {
                String path = event.getDataItem().getUri().getPath();

                if(path.equals("/DataService_Path")) {
                   // change list
                 }
   }
 }

I am stuck here, thank you for help in advance

Shruti
  • 391
  • 1
  • 5
  • 21
  • Would http://stackoverflow.com/questions/24676165/unable-to-push-data-to-android-wear-emulator/24697312#24697312 help you? – Louis CAD Feb 19 '16 at 10:20

1 Answers1

0

Did you connect to the googleclientapi in your service?

mGoogleApiClient = new GoogleApiClient.Builder(context) .addApi(Wearable.API) .addConnectionCallbacks(this) .build(); mGoogleApiClient.connect()

Also check this post:

WearableListenerService, onDataChanged() is not called

dazza5000
  • 7,075
  • 9
  • 44
  • 89
  • googleApiClient is connect properly and mandatory permissions is also defined in manifest file, cos when we send request from wear, data comes in array list in WearableService – Shruti Sep 14 '15 at 06:02