I followed the tutorial to invoke a Wearable activity from phone, posted here How to send notification from handheld to wear to open Activity on wear device. However, I grab
If you are using Android Wear emulator than be sure that Android Wear app on the phone has Connected to the emulator and you run adb tcp forwarding command.
Additional details here: https://stackoverflow.com/a/25506889/1044864
For me, the culprit was this line in the service declaration:
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"
I'm not exactly sure what about this line causes the service not to receive events, but when it was removed it started functioning properly.
after onDataChanged method, I am forcing
onDataChanged(DataEventBuffer dataEvents) {
--doDataStuff---
mGoogleApiClient.disconnect(); mGoogleApiClient.connect();
}
only with this setting the onDataChanged is working for me.
1.check build.gradle for mobile and for wear to have the same play version compile 'com.google.android.gms:play-services-wearable:6.5.87'
Mine has a + sign on mobile and it took the last version on mobile only
Upgrade same version on both until it works
2.Stupid workaround, if nothing works (!! this works with different play versions on pairs, if you do step one you do not need this)
....
Wearable.DataApi.putDataItem(mGoogleApiClient, request)
.......
this line after your put
Wearable.DataApi.deleteDataItems(mGoogleApiClient, request.getUri());
It is a replication trick that do 3 things :
wake up pair
send data
execute OnDataChange on both with good data
delete data (execute OnDataChange on both with no data) (so prepare to work even after the data was deleted)
My problem was that data was queued and paused on watch until first touch - now it is real time bidirectional
There are two things you can check:
packageName
of the wear app should be identical to packageName
of the device apponDataChanged()
gets only called when the data really changes. If you put the same data into the DataApi multiple times, the method is only called once until you write different data. You could add a timestamp to the data to make sure that the method gets called once for each write operation. However, using the DataApi is potentially more expensive in terms of battery usage than sending a message. So if you just want to trigger an action after putting data into the DataApi, simply send a message when you are done.make sure that the applicationId in the build.gradle file ist the same for your handheld and your wearable module
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "your.applicationid" // needs to be the same in both modules
minSdkVersion 20
targetSdkVersion 23
versionCode 1
versionName "1.0"
targetCompatibility = '1.7'
}
...