title: android wear message to handheld
body: <p>I am using the Android Wearable API to send a simple string message to my handheld device. The message sending is implemented succesfully, the status of the message is SUCCES.</p>
  
  <p>I created a service to receive messages, but it is not working. Every time I send an message from the wearable app the onConnected callback method is calling. Very weird. I show the code:</p>
  
  <p>Service:</p>
  
  <pre><code>public class MobileService extends WearableListenerService {
  private String TAG = "TAG_SERVICE";
  private GoogleApiClient mGoogleApiClient;
  
  @Override
  public void onCreate() {
      super.onCreate();
  
      mGoogleApiClient = new GoogleApiClient.Builder(this)
              .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();
      mGoogleApiClient.connect();
  }
  
  @Override
  public void onMessageReceived(MessageEvent messageEvent) {
      Log.v(TAG, "Message received!");
      super.onMessageReceived(messageEvent);
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Logcat of the receiving service, when I send message: (very weird)</p>
  
  <pre><code>02-13 18:25:50.652 21490-21490/hu.padar.app.todo D/TAG_SERVICE: onConnected: null
  </code></pre>
  
  <p>Manifest mobile:</p>
  
  <pre><code> &lt;service android:name="hu.padar.app.todo.MobileService"&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;/application&gt;
  
  &lt;meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /&gt;
  </code></pre>
  
  <p>And the applicationId is the same in both gradle files.</p>
  
  <p>I add some extra information. This is where I send the message:</p>
  
  <pre><code>            if (transcriptionNodeId != null) {
              Wearable.MessageApi.sendMessage(mGoogleApiClient, transcriptionNodeId,
                      MESSAGE_PATH, "my message".getBytes()).setResultCallback(
                      new ResultCallback() {
                          @Override
                          public void onResult(Result result) {
                              Log.d(TAG, result.getStatus().toString());
                          }
                      }
              );
          } else {
              Log.d(TAG, "Unable to send message!");
          }
  </code></pre>
  
  <p>This is where I initialize the GoogleApiClient object:</p>
  
  <pre><code> mGoogleApiClient = new GoogleApiClient.Builder(getApplicationContext())
                      .addApi(Wearable.API)
                      .build();
              mGoogleApiClient.connect();
  
              updateNodeId();
  </code></pre>
  
  <p>The updateNodeId() method only puts the correct Node Id to transcirptionNodeId.</p>
  
  <p>Wear dependencies are the following in build.gradle:</p>
  
  <pre><code>dependencies {
  compile fileTree(dir: 'libs', include: ['*.jar'])
  compile 'com.google.android.support:wearable:1.3.0'
  compile 'com.google.android.gms:play-services-wearable:8.4.0'
  }
  </code></pre>
  
  <p>Mobile dependencies are the following in build.gradle:</p>
  
  <pre><code>dependencies {
  compile fileTree(dir: 'libs', include: ['*.jar'])
  wearApp project(':wear')
  testCompile 'junit:junit:4.12'
  compile 'com.android.support:appcompat-v7:23.1.1'
  compile 'com.google.android.gms:play-services:8.4.0'
  }
  </code></pre>