0

I have a weird issue. I'm using the DataClient class to transfer data from a phone app to a WearOS app. It was working fine for years, then after the recent upgrade to WearOS 6, onDataChanged in the WearableListenerService stops responding after the phone has been idle for awhile, like overnight.

As a test, I added some MessageClient code to the phone app and onMessageReceived in the watch app was hit while onDataChanged wasn't. It's only DataClient that is not working.

What is even stranger is if I Force Close the phone app, onDataChanged is hit in the watch app, as if the requests were queued on the phone.

Rebooting the phone sometimes fixes it. Rebooting the watch does not fix it though.

The Phone is a Pixel 9a running Android 16. The watch is a Galaxy Watch 7 running WearOS 6.

Phone App:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
   
    PutDataMapRequest dataMapRequest = PutDataMapRequest.create("/watch");
    DataMap dataMap = dataMapRequest.getDataMap();
    dataMap.putString("key", "value");

    Wearable.getDataClient(this).putDataItem(dataMapRequest.asPutDataRequest())
    .addOnSuccessListener(dataItem -> {
            //this is hit on the phone
    })                      
}
   

Watch App:

    public class WearableService extends WearableListenerService {

        @Override
        public void onDataChanged(DataEventBuffer dataEvents) {

                //never called on the watch
        }
    }
    

This code in the phone app worked:

 Wearable.getNodeClient(this).getConnectedNodes().addOnSuccessListener(nodes -> {
    for (Node node : nodes)
        Wearable.getMessageClient(mContext).sendMessage(node.getId(), "/test", null);
});

Watch app:

@Override
public void onMessageReceived(MessageEvent messageEvent) {
    //this is hit
}

1 Answer 1

0

Hopefully this helps someone in the future but if use setUrgent() on the PutDataMapRequest object, it fixes the issue.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.