21

I have installed new android wear SDK. Also have downloaded Android wear app from play store on my phone. I am able to connect my phone with Android wear simulator.

Now I want to give android wear support to an exisitng app. How do I achieve this?

Thanks in advance.

Ahmed Faisal
  • 4,397
  • 12
  • 45
  • 74
Bhavana
  • 219
  • 2
  • 6
  • 3
    people don't seem to understand your question. The docs assume you are creating a new app. What about an existing app? How do you integrate the wear project? Lemme know if you figure it out. – Marty Miller Oct 08 '14 at 09:26

3 Answers3

14

You need to import an Android Wear module. Right click on the your project and select "Open Module Settings" Then click the "plus" button which should bring up a wizard to add a Wear Module.

Marty Miller
  • 913
  • 2
  • 11
  • 27
  • 2
    but this is creating new module right? Instead of extending current app to have wear functionality. Let say I have an AppWidget can I join these 2 functionalities into 1 module or should I separate AppWidget from Wearable? http://stackoverflow.com/questions/27643879/extending-appwidget-to-wearable-app – stuckedunderflow Jan 26 '15 at 04:25
  • 1
    Sorry for the late reply. The way you add wear functionality is by adding a wearable module. You should end up with two modules, one for your main device and one for your wearable. – Marty Miller Feb 26 '15 at 19:49
  • hey so I did this and I end up with two modules one for phone another for wear, when I go to run I have to select either my phone app or the watch app. Is this the correct setup ?? orr should the wear manifest match the phone manifest as I have seen on other guides. Thanks ! – Doug Ray Jan 26 '16 at 22:46
  • That's correct. The wear manifest and phone manifest can still match with this setup – Marty Miller Aug 18 '16 at 18:16
4

There are two parts to adding a wear module to existing android app. 1. Adding the module itself 2. Packaging it with existing android module

Marty has already explained the 1st part let me add details of the 2nd one -

  1. Include all the permissions declared in the manifest file of the wearable app module in the manifest file of the handheld app module.
  2. Ensure that both the wearable and handheld app modules have the same package name and version number.
  3. Declare a Gradle dependency in the handheld app's build.gradle file that points to the wearable app module:

dependencies { compile 'com.google.android.gms:play-services:5.0.+@aar' compile 'com.android.support:support-v4:20.0.+'' wearApp project(':wearable') }

References

  1. https://developer.android.com/studio/projects/add-app-module.html
  2. https://developer.android.com/training/wearables/apps/packaging.html
Aniket Thakur
  • 66,731
  • 38
  • 279
  • 289
2

If anyone would still struggle the issue.

Short answer. Add this feature to your app manifest:

<uses-feature android:name="android.hardware.type.watch" />

Longer answer. It depends. I'm assuming that you have a mobile app, and you just want to to publish for the wear. In that case you need to create separate flavor of your app, which includes the feature from above and changes the target API. FYI Wear ecosystem is a bit different from mobile, ex before 23 there is no direct internet access, no keyboard and no accounts. So you probably want to target minApi 23 for wear flavor.

Further reading: https://developer.android.com/training/wearables/apps/standalone-apps

slfan
  • 8,950
  • 115
  • 65
  • 78
promanowicz
  • 399
  • 2
  • 10