I am trying the dataitem APi and here is my code
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() {
@Override
public void onConnected(Bundle connectionHint) {
Log.d("Inside", "onConnected: " + connectionHint);
Toast.makeText(getApplicationContext(),"Inside On connected",Toast.LENGTH_SHORT).show();
// Now you can use the Data Layer API
//Creating Dataitem
PutDataMapRequest dataMapRequest = PutDataMapRequest.create("/count");
dataMapRequest.setUrgent();
DataMap datamap=dataMapRequest.getDataMap();
PutDataRequest putDataRequest=dataMapRequest.asPutDataRequest();
datamap.putString("key", "Value");
PendingResult<DataApi.DataItemResult> pendingResult =
Wearable.DataApi.putDataItem(mGoogleApiClient, putDataRequest);
}
@Override
public void onConnectionSuspended(int cause) {
Log.d("Inside", "onConnectionSuspended: " + cause);
}
})
.addOnConnectionFailedListener(new GoogleApiClient.OnConnectionFailedListener() {
@Override
public void onConnectionFailed(ConnectionResult result) {
Log.d("Inside", "onConnectionFailed: " + result);
}
})
// Request access only to the Wearable API
.addApiIfAvailable(Wearable.API)
.build();
mGoogleApiClient.connect();
}
@Override
public void onDataChanged(DataEventBuffer dataEventBuffer) {
Log.d("Inside","onDataChanged");
}
What am I missing out to trigger on data changed?. I read this and this but I am still unclear what am I supposed to change to enter on data changed