How to send notification from handheld to wear to open Activity on wear device

The pattern to use for this is:

  1. Create a DataItem on the mobile. It will be synced to the connected wearable automatically.
  2. On the wearable, implement a WearableListenerService and listen for onDataChanged events.
  3. When you receive a DataItem, create a notification (with the data sent in the DataItem) and send it locally (i.e. on the wearable). Use setContentIntent() on the notification to specify a pending intent that will launch your wearable activity.
  4. Don’t forget to also provide an intent that is fired when the user dismisses the notification on the wearable, so that the DataItem can be removed. Otherwise, you will not receive any update events.

I’ve created a sample project that shows all of this in action.

Check out this question if the onDataChanged method is not getting called.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)