Android wear action remotely activates a service in handheld

51 views Asked by At

This seems like a simple thing to do, but there's very little documentation on this.

I want to send a demand to an android wear device like so when the user enters a specific activity:

enter image description here

then if the user is looking at his or her watch and presses the demand button, it does the same thing as pressing an identical button in the handheld app.

How can I accomplish this?

Specifically:

if (userPressedDemandButton) {
    if (!service.isRunning)
        service.start();
    else
        service.stop();
}

I know how to get a demand button to show up on a wear device like so, but I don't know how to send a message back to the handheld when the user presses the demand button.

1

There are 1 answers

0
Nick Moskalenko On

You can't access handheld device directly from wearable notification. You should setup notification action handler, use MessageAPI in it to send some action to handled and there do everything you want.