2

I've created a couple of apps that can communicate with the watch using GoogleApiClient. It worked perfectly fine, but one day ago, every app I used this interface stopped receiving messages from the mobile device and could only send messages. The mobile received the messages but it seems that onMessageReceived() method on the wear never triggered as before. Why? Is it a software update? how can I solve this? (Data layer API doesn't work for my API level. only GoogleApiClient). Why is it one-way communication suddenly? (NOTE: I did not change any code)

Wear os:

class WearService : WearableListenerService() {
    lateinit var googleApiClient: GoogleApiClient

    override fun onCreate() {
        super.onCreate()
        println("WearService onCreate")

        initializeGoogleApiClient()
    }

    override fun onMessageReceived(messageEvent: MessageEvent) {
        super.onMessageReceived(messageEvent)

        if (messageEvent.path == PATH) {
            val message = String(messageEvent.data)
            println("WearService message: $message")

            postToActivity(message)
        }
    }
}

Mobile:


class MainActivity : AppCompatActivity() {
    lateinit var startServiceMaterialButton: MaterialButton
    lateinit var receiver: BroadcastReceiver
    lateinit var watchStateTextView: TextView
    lateinit var serviceStateTextView: TextView
    var countdownTimer: CountDownTimer? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        startService()
        initializeReceiver()

        sendAlive() # Send every 1 second
    }

Update: Now it's working and i don't even know why. I didn't change a thing. This OS is weird

1
  • Happened to me too, I think it might be the new version of Android for the wear. Even though it didn't happen right after the update... Commented Oct 11, 2023 at 12:50

0

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.