https://kotlinlang.org logo
Title
a

Arjun Achatz

03/24/2023, 12:58 AM
When we call 'dataClient.getDataItem(xyz).await()' do we need to call release on the 'DataItemBuffer' item that gets returned once we're done using it ?
h

Hardik Khandelwal

03/24/2023, 12:19 PM
Based on the API documentation: https://developers.google.com/android/reference/com/google/android/gms/wearable/DataClient#public-abstract-taskdataitembuffer-getdataitems-uri-uri Callers must call
AbstractDataBuffer.release()
on the returned buffer when finished processing results. Hence you should release the items.
a

amoledwatchfaces

04/08/2023, 7:56 AM
Should I use the same here?
I don't know why but DataLayer / WearableListenerService is so unreliable for me with the latest Play Services. Works good only with Bluetooth turned on. (Galaxy Watch4)
y

yschimke

04/08/2023, 8:11 AM
BT is usually on when available, so you will have a persistent connection. You should assume when BT is not available and you are on Wifi/LTE that you only occasionally have a network. I'm not sure it's what you are seeing, but expect more delays when not on BT.
a

amoledwatchfaces

04/08/2023, 8:13 AM
I'm using it for simple communication, send request to phone, phone sends phone battery back to watch. I'm using setUrgent and also sending system.currentTimeinMillis to ensure every data sending task is different (I assume this is needed for listener to receive event)
y

yschimke

04/08/2023, 8:14 AM
Is it just delay/unpredictable behaviour, or does it never arrive?
a

amoledwatchfaces

04/08/2023, 8:17 AM
Arrives when I enable BT. With Wifi / Data it acts unpredictable. Sometimes works, sometimes not at all. I thought that this was an issue of the previous Play Store Services (23.07.14) but this behavior seems to appear back with every other Play Services update
I'm on latest 23.12.13 (both phone / watch)
What's even more interesting, same build works fine when I use signed apps installed via adb (sending and receiving messages instantly) but when I upload it to the internal test, it only works via BT
Discard. Must be an issue with my watch. It works instantly on emulator / Fossil Gen 6 with same Play Services version. So the issue must be on Samsungs end. Anyway, should I use AbstractDataBuffer.release() in my code?
l

louiscad

04/08/2023, 11:57 AM
@amoledwatchfaces Yes you should
a

amoledwatchfaces

04/08/2023, 12:00 PM
@louiscad I'm asking because in the link above, it's only mentioned under DataItemBuffer and in my code, I'm only using DataEventBuffer
l

louiscad

04/08/2023, 12:03 PM
Oh, then it shouldn't be needed unless you are using the objects beyond the callback (in which case you should also call freeze() first and foremost) @amoledwatchfaces
a

amoledwatchfaces

04/08/2023, 12:05 PM
@louiscad So using it like here, only inside onDataChange, should be fine, yes?
IMG_20230408_140558_195.png
l

louiscad

04/08/2023, 12:41 PM
Should be fine
a

amoledwatchfaces

04/08/2023, 1:01 PM
Thanks šŸ™‚
@yschimke now experiencing the same also on emulator / Fossil Gen 6. Interestingly, everything works instantly fast with signed apk. When I upload same build (aab) to the internal test, apps cannot communicate via WiFi or mobile data. Maybe it's something which needs to be excluded in the build.gradle?
Based on logcat, wearable service datalayer send task finishes correctly but mobile WearableListenerService is not responding
a

Arjun Achatz

04/09/2023, 5:42 PM
Yeah I find this happens as well; can you try wiping the emulator, starting it back up, install your app fresh, and then see what happens?
a

amoledwatchfaces

04/09/2023, 5:46 PM
@Arjun Achatz I'm using wear os emulator and it is connected to my phone. I think the mobile part is the problem because I'm pretty sure watch app is sending data task successfully. I'll try two emulators then. Any Idea why everything works fine when I install signed apks but not work when I upload aabs to the internal / public release?
a

Arjun Achatz

04/09/2023, 5:48 PM
I also use a wear emulator paired with a physical device. The same thing happens to me every now and then and it drives me bonkers. What I meant was could you wipe your wear emulator and install the app fresh, and then see what happens
a

amoledwatchfaces

04/09/2023, 5:49 PM
Ok, going to try that
But should I install release from play store? Because when I install both apps with adb install, they will communicate just fine.
@Arjun Achatz So, it works now. So the wearable is completing sending task but actually does not send any request?
Isn't this some bug / error within Wear OS or Play Services?
a

Arjun Achatz

04/09/2023, 6:06 PM
It's definitely something šŸ˜… @louiscad ^
a

amoledwatchfaces

04/09/2023, 6:12 PM
@Arjun Achatz @louiscad wiped also Galaxy Watch4 and communication works fine too. We can't expect from users to do this. When this error occurs it's basically impossible for user to use our apps when their device are not connected with BT. I'll try to wipe cache / force stop play services on my Gen 6. If it helps, then it's definitely some issue between Play Services Updates (Wear OS)
a

Arjun Achatz

04/09/2023, 6:16 PM
Not sure who the right person is but we definitely need to escalate it. Maybe you can report it as an issue ?
y

yschimke

04/09/2023, 6:18 PM
Definitely report an issue, even if you found a workaround, it should obviously work without such effort.
a

amoledwatchfaces

04/09/2023, 6:20 PM
@yschimke I'm new to this. Should I use Google Issue tracker page?
y

yschimke

04/09/2023, 6:49 PM
This isn't exactly the right link, but this is probably the best place to start. https://developer.android.com/jetpack/androidx/releases/wear#feedback
a

amoledwatchfaces

04/10/2023, 4:08 AM
Thanks šŸ™‚
y

Yingding Wang

04/10/2023, 6:38 PM
I always check the available node from CapacityClient, before i send any data between the wear and android apps. I will inform user to reconnect BT. Sometime, the connection just lost.
a

amoledwatchfaces

04/10/2023, 7:08 PM
Problem is that the node is actually connected. Not nearby, but definitely connected because I even can remotely open play store app on it. (remote activity helper). Also, we're talking about devices connected with WiFi/ mobile data. Via BT, everything works fine