0

I am trying to transfer heart rate sensors data from watch to mobile device. On the watch(wearable) side, I am getting message stating that the data has been transferred. I have set the priority of the message(PutDataMapRequest) as urgent on the watch.

However, I am unable to receive the data on the mobile device. Following is my code for AndroidManifest.xml:

<%service android:name=".WearableListenerService1">
    
<%intent-filter>
    
<%action android:name="com.google.android.gms.wearable.DATA_CHANGED" />
    
<%data android:host="*"  android:scheme="wear" android:pathPrefix= "/healthcare" />
    
</intent-filter>
</service>

My WearableListenerService1 class is:

    public class WearableListenerService1 extends WearableListenerService     {
        @Override
    public void onMessageReceived(MessageEvent messageEvent) {
        super.onMessageReceived(messageEvent);

        String event = messageEvent.getPath();

        Log.d("Event ", event);

        String [] message = event.split("--");
        Intent i = new Intent(this, MainActivity.class);
        startActivity(i);
    }

    @Override
    public void onDataChanged(DataEventBuffer dataEventBuffer) {
      //  super.onDataChanged(dataEventBuffer);
        Log.d("Event ", "event data changed");
        Intent i = new Intent(this, MainActivity.class);
        startActivity(i);

    }
}

I am using following libraries:

compile 'com.google.android.support:wearable:2.0.0-alpha2'
compile 'com.google.android.gms:play-services-wearable:9.4.0'
halfer
  • 19,824
  • 17
  • 99
  • 186

2 Answers2

0

Acording to this tutorial, make sure that the applicationId in the main app and wearable app are matched (build.gradle files) in order for the WearableListenerService to fire the onDataChanged event. Because when you send some data through mobile app or wear app, it will check for the same package to pass that data. So if you give different name, you won't be able to send or receive data.

You can also check this documentation and related SO threads:

Community
  • 1
  • 1
abielita
  • 13,147
  • 2
  • 17
  • 59
0

I found the issue. Android version on my Moto360 was 1.5 whereas I was using developer preview of wear 2.0 on Android Studio.