title: Android wear module listener service not receiving data from mobile module
body: <p>I am developing a sample watch face wherein a user would be able to select some color configuration on mobile app triggering changes on wear app watch face.</p>
  
  <p>Here is what I have in mobile app to send configuration:</p>
  
  <pre><code>package com.quicklyjava.templatewatchface;
  
  import android.content.Context;
  import android.os.Bundle;
  import android.util.Log;
  
  import com.google.android.gms.common.ConnectionResult;
  import com.google.android.gms.common.api.GoogleApiClient;
  import com.google.android.gms.common.api.PendingResult;
  import com.google.android.gms.common.api.ResultCallback;
  import com.google.android.gms.wearable.DataApi;
  import com.google.android.gms.wearable.PutDataMapRequest;
  import com.google.android.gms.wearable.PutDataRequest;
  import com.google.android.gms.wearable.Wearable;
  
  /**
   * Created by P
   */
  public class WearConnection {
  
  private final GoogleApiClient mGoogleApiClient;
  private String TAG = "wear.bridge";
  
  public WearConnection(Context context) {
      mGoogleApiClient = new GoogleApiClient.Builder(context)
              .addConnectionCallbacks(new GoogleApiClient.ConnectionCallbacks() {
                  @Override
                  public void onConnected(Bundle connectionHint) {
                      Log.d(TAG, "onConnected: " + connectionHint);
                  }
  
                  @Override
                  public void onConnectionSuspended(int cause) {
                      Log.d(TAG, "onConnectionSuspended: " + cause);
                  }
              })
              .addOnConnectionFailedListener(new GoogleApiClient.OnConnectionFailedListener() {
                  @Override
                  public void onConnectionFailed(ConnectionResult result) {
                      Log.d(TAG, "onConnectionFailed: " + result);
                  }
              })
              .addApi(Wearable.API)
              .build();
  
  }
  
  public void connect(){
      mGoogleApiClient.connect();
  }
  
  public void disconnect() {
      mGoogleApiClient.disconnect();
  }
  
  public void sendColor(String path, int color) {
      PutDataMapRequest dataMap = PutDataMapRequest.create(path);
      dataMap.getDataMap().putInt("value", color);
      PutDataRequest request = dataMap.asPutDataRequest();
      PendingResult&lt;DataApi.DataItemResult&gt; pendingResult = Wearable.DataApi.putDataItem(mGoogleApiClient, request);
      pendingResult.setResultCallback(new ResultCallback&lt;DataApi.DataItemResult&gt;() {
          @Override
          public void onResult(DataApi.DataItemResult dataItemResult) {
              Log.d("wear", "sent: " + dataItemResult);
          }
      });
  
  }
  
  }
  </code></pre>
  
  <p>Here is the manifest for mobile:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.quicklyjava.templatewatchface" &gt;
  
  &lt;uses-permission android:name="com.google.android.permission.PROVIDE_BACKGROUND" /&gt;
  &lt;uses-permission android:name="android.permission.WAKE_LOCK" /&gt;
  
  &lt;application
      android:allowBackup="true"
      android:icon="@drawable/ic_launcher"
      android:label="@string/app_name"
      android:theme="@style/AppTheme" &gt;
  
      &lt;meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /&gt;
  
      &lt;activity
          android:name=".MainActivity"
          android:label="@string/app_name" &gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
  
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
  
  
      &lt;/activity&gt;
  &lt;/application&gt;
  </code></pre>
  
  <p></p>
  
  <p>Here is the listener service I implemented in wear:</p>
  
  <pre><code>package com.quicklyjava.templatewatchface;
  
  import android.content.Intent;
  import android.content.SharedPreferences;
  import android.net.Uri;
  import android.preference.PreferenceManager;
  import android.util.Log;
  
  import com.google.android.gms.common.ConnectionResult;
  import com.google.android.gms.common.api.GoogleApiClient;
  import com.google.android.gms.common.data.FreezableUtils;
  import com.google.android.gms.wearable.DataEvent;
  import com.google.android.gms.wearable.DataEventBuffer;
  import com.google.android.gms.wearable.DataMapItem;
  import com.google.android.gms.wearable.Node;
  import com.google.android.gms.wearable.Wearable;
  import com.google.android.gms.wearable.WearableListenerService;
  
  import java.util.List;
  import java.util.concurrent.TimeUnit;
  
  /**
   * Created by P
   */
  public class TemplateWatchConfigListenerService extends WearableListenerService {
  
  private static final String TAG = "DataLayerSample";
  private SharedPreferences preferences;
  
  //  keys for the data map
  private String KEY_DOT_COLOR="com.quicklyjava.backgroundcolor";
  
  GoogleApiClient mGoogleApiClient;
  
  @Override
  public void onCreate() {
      super.onCreate();
  
      mGoogleApiClient = new GoogleApiClient.Builder(this)
              .addApi(Wearable.API)
              .build();
  
      mGoogleApiClient.connect();
  
      preferences = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
  }
  
  @Override
  public void onDataChanged(DataEventBuffer dataEvents) {
      LOGD(TAG, "onDataChanged: " + dataEvents);
  
      final List&lt;DataEvent&gt; events = FreezableUtils.freezeIterable(dataEvents);
      dataEvents.close();
  
      if(!mGoogleApiClient.isConnected()) {
          ConnectionResult connectionResult = mGoogleApiClient.blockingConnect(30, TimeUnit.SECONDS);
  
          if (!connectionResult.isSuccess()) {
              Log.e(TAG, "WatchFaceConfigListenerService failed to connect to GoogleApiClient.");
              return;
          }
      }
  
      // Loop through the events and send a message back to the node that created the data item.
      for (DataEvent event : events) {
          Uri uri = event.getDataItem().getUri();
          String path = uri.getPath();
  
          DataMapItem item = DataMapItem.fromDataItem(event.getDataItem());
  
          switch (path) {
              case "/backgroundColor":
                  putIntPreference(KEY_DOT_COLOR, item.getDataMap().getInt("value"));
                  break;
  
              default:
                  Log.e("TempWatchList","Default");
  
          }
  
          getBaseContext().sendBroadcast(new Intent("com.quicklyjava.action.config_changed"));
  
      }
  }
  
  @Override
  public void onPeerConnected(Node peer) {
      LOGD(TAG, "onPeerConnected: " + peer);
  }
  
  @Override
  public void onPeerDisconnected(Node peer) {
      LOGD(TAG, "onPeerDisconnected: " + peer);
  }
  
  public static void LOGD(final String tag, String message) {
      if (Log.isLoggable(tag, Log.DEBUG)) {
          Log.d(tag, message);
      }
  }
  
  private void putIntPreference(String key, int value) {
      preferences
              .edit()
              .putInt(key, value)
              .apply();
  }
  }
  </code></pre>
  
  <p>Finally here is the wear manifest:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.quicklyjava.templatewatchface" &gt;
  
  &lt;uses-sdk android:minSdkVersion="21"
      android:targetSdkVersion="21" /&gt;
  
  &lt;uses-feature android:name="android.hardware.type.watch" /&gt;
  
  &lt;!-- Required to act as a custom watch face. --&gt;
  &lt;uses-permission android:name="com.google.android.permission.PROVIDE_BACKGROUND" /&gt;
  &lt;uses-permission android:name="android.permission.WAKE_LOCK" /&gt;
  
  &lt;application
      android:allowBackup="true"
      android:icon="@drawable/ic_launcher"
      android:label="@string/app_name" &gt;
  
  
      &lt;service
          android:name=".TemplateWatchService"
          android:label="@string/template_name"
          android:permission="android.permission.BIND_WALLPAPER" &gt;
          &lt;meta-data
              android:name="android.service.wallpaper"
              android:resource="@xml/watch_face" /&gt;
          &lt;meta-data
              android:name="com.google.android.wearable.watchface.preview"
              android:resource="@drawable/preview_digital" /&gt;
          &lt;meta-data
              android:name="com.google.android.wearable.watchface.preview_circular"
              android:resource="@drawable/preview_digital_circular" /&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.service.wallpaper.WallpaperService" /&gt;
              &lt;category android:name="com.google.android.wearable.watchface.category.WATCH_FACE" /&gt;
          &lt;/intent-filter&gt;
      &lt;/service&gt;
  
      &lt;service android:name=".TemplateWatchConfigListenerService" &gt;
          &lt;intent-filter&gt;
              &lt;action android:name="com.google.android.gms.wearable.BIND_LISTENER" /&gt;
          &lt;/intent-filter&gt;
      &lt;/service&gt;
  
      &lt;meta-data
          android:name="com.google.android.gms.version"
          android:value="@integer/google_play_services_version" /&gt;
  
  &lt;/application&gt;
  </code></pre>
  
  <p></p>
  
  <p>The onDataChanged method is not getting triggered when the sendColor method in mobile app is called. Is there anything I am missing? </p>