Reputation: 335
Sorry if this sounds like a lazy question, but I've Googled and couldn't find an answer: I suspect this is because it can't be done as I describe below.
I have an app which runs on the phone for remote controlling power devices. At the moment, users can create a home screen icon on the phone, which fires an intent on the phone which launches my app in the background to execute various macros.
I want to extend this functionality to Android Wear devices, i.e.
1) on the phone, the user would press a button which would programmatically create an icon on the Android Wear device (e.g. in Wear Mini Launcher), which would have an intent associated with it.
2) when the icon was pressed on the Wear device, it would fire the intent on the phone to launch the main app on the phone in the background which would then execute on the phone.
Is this even possible? I would like to avoid having to write a specific app for the Wear device if possible.
Any suggestions welcome, or code snippets would be even better! Thanks.
Andrew
Upvotes: 0
Views: 1611
Reputation: 4835
You can do some of what you want, I'll break it down into your separate questions.
1) You would create a mobile and wear app, when the mobile app is installed it will install the wear app as well. There's no way to install them otherwise.
2) On the mobile app you could create a wearable listener service that would respond to messages from the wear app. On the wear app when you do your initial launch of your activity you could send a message to the listener service via the wear messaging api and the finish. Within the mobile wearable listener service upon receiving the message you would launch your intent.
Here's a pretty good example of how to do this - Wear Messaging API example
Upvotes: 2