Kei
Kei

Reputation: 65

Android Wear message sent from watch is not received by the phone devie

I want to send message from Watch to my phone. I can send a message using MessageAPI to my phone, and the result is successful too by looking at the log message. However, the message is not received on the phone's side.

Wearable.MessageApi.sendMessage(mGoogleApiClient, mNode.getId(),
                    MY_DATA_PATH, null).setResultCallback(

            new ResultCallback<MessageApi.SendMessageResult>() {
                @Override
                public void onResult(
                        MessageApi.SendMessageResult sendMessageResult) {

                    if (!sendMessageResult.getStatus().isSuccess()) {
                        Log.d("TAG",
                                "sendMessageResult NOT successful");
                    } else {
                        Log.d("TAG",
                                "sendMessageResult successful");
                    }
                }
            });

However, on my phone's listener service, onMessageReceived and onPeerConnected are not called.

public class ListenerServiceFromWear extends WearableListenerService {

private static final String My_DATA_PATH = "/my-data-path";

@Override
public void onMessageReceived(MessageEvent messageEvent) {
    Log.d("TAG", "onMessageReceived");

    /*
     * Receive the message from wear
     */
    if (messageEvent.getPath().equals(MY_DATA_PATH)) {

        Intent startIntent = new Intent(this, ContactActivity.class);
        startIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(startIntent);
    }

}



@Override
public void onPeerConnected(Node node){
    Log.d("TAG", "onPeerConnected");
}

}

Here is the phone app's Manifest declaration for the ListenerService:

<service android:name="com.mobile.rbc.services.ListenerServiceFromWear" >
        <intent-filter>
            <action android:name="com.google.android.gms.wearable.BIND_LISTENER" />
        </intent-filter>
    </service>

Upvotes: 1

Views: 490

Answers (1)

Kei
Kei

Reputation: 65

Found the answer. The problem is that the Android Wear's apk is signed and the Phone's apk is not signed.
I was debugging it using Eclipse, that's why the phone's app is not signed. Usually you will see something in your log if the two apks are not signed with the same key.

ensureBindStarted: app does not match record's app key: AppKey

Upvotes: 4

Related Questions