I'm wondering if it is possible to send notification from handheld (android phone) to wear device to open Activity on wear device? What I want to do is as following.
So far, I checked the following documents, but it's different from what I want to do.
- Adding Wearable Features to Notifications
- What is described here is sending notification from phone to wear, then open activity on the phone (I want to open activity on the wear)
- Create Custom Notifications
- What is described here is sending notification from wear to wear, then open activity on the wear (I want to send notification from phone to wear)
Any ideas?
The pattern to use for this is:
WearableListenerService
and listen foronDataChanged
events.DataItem
, create a notification (with the data sent in theDataItem
) and send it locally (i.e. on the wearable). UsesetContentIntent()
on the notification to specify a pending intent that will launch your wearable activity.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.I think in most cases it would be better to include your app activity inside the notification. For example, instead of the "Open" button in your notification, you could use setDisplayIntent(notificationPendingIntent) to display an activity as part of the notification as described here: http://developer.android.com/training/wearables/apps/layouts.html
This gives you a best of both worlds situation between having an app and a notification.