Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.wearconnectivityexample.service

import android.util.Log
import android.os.Handler
import android.os.Looper
import com.google.android.gms.wearable.Asset
import com.google.android.gms.wearable.DataEvent
import com.google.android.gms.wearable.DataEventBuffer
Expand All @@ -25,7 +27,7 @@ class WearDataListenerService : WearableListenerService() {
}
}

fun saveReceivedFile(asset: Asset) {
private fun saveReceivedFile(asset: Asset) {
val dataClient = Wearable.getDataClient(this)
val task = dataClient.getFdForAsset(asset)

Expand All @@ -36,7 +38,9 @@ class WearDataListenerService : WearableListenerService() {
inputStream.copyTo(outputStream)
}
// Update the shared state (ensure this runs on the main thread)
FileState.imagePath = file.absolutePath
Handler(Looper.getMainLooper()).post {
FileState.imagePath = file.absolutePath
}
}
Log.w("WearOS", "File transfer successful")
}.addOnFailureListener { e ->
Expand Down