WearableListenerService, onDataChanged() is not called

前端 未结 7 941
野趣味
野趣味 2020-12-11 01:05

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

7条回答
  •  Happy的楠姐
    2020-12-11 01:24

    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

提交回复
热议问题