How to develop watch face with wearable app in android? - android

I am new in Android wearable app development and recently I came to know that Watch Face API is also now available for Android. So I want to develop wearable app of my mobile app and also I want to develop watch face of that same app.
Can anyone suggest me is this possible or not? As I know that the layout file of wearable app and watch face are same (activity_main.xml). So how can I develop design of watch and wearable app?
I am stuck with this confusion. Please let me know the feasibility.
Thanks in advance.

For creating a watchface you need to create a service using CanvasWatchFaceService class
Watch faces in Android Wear are implemented as services. When a watch
face is active, the system invokes the methods in its service when the
time changes or when an important event occurs (like switching to
ambient mode or receiving a new notification). The service
implementation then draws the watch face on the screen using the
updated time and any other relevant data.
You may follow this https://developer.android.com/training/wearables/watch-faces/designing.html step by step to create your watchface

For wear development, refer to the following:
Creating and running a wearable app
You can run a debug wearable app over bluetooth by following this reference:
Debugging over bluetooth
If you want to test your app on the android wear handheld application, you will need to build a signed release apk and upload it to your mobile device.
For this procedure, read the following:
Assuming you use android studio:
Your mobile build.gradle file should have the following dependency:
dependencies {
...
wearApp project(':wear')
}
Go to Build > Generate signed apk. In the first window, select mobile as your module.
Now when the build is complete, the wear module will automatically be embedded into the mobile module. The mobile apk is the one you distribute. Wear can be used for testing.

Related

Android Wear 2.0 developing a complication

I've got an existing Android app that I'd like to provide a wear 2.0 complication for. I do not wish to create a custom Wear Watch Face nor a companion Wear app - I simply wish to be able to create a complication that users should be able to add to an existing watch face. Is this possible? Reading the documentation it seems to me that I would need to create a custom Watch Face or an app in order to provide a complication. I'm now a little confused. Any directions on this would be appreciated.
You don't need to develop a watch face, but you do need an app running on the watch to deliver a complication. It doesn't need any other UI (such as an Activity) unless your complication requires it for configuration, but the ComplicationProviderService does need to be in an APK running on the watch.

Creating and running an Android wear app

Based on the Android docs (https://developer.android.com/intl/pt-br/training/wearables/apps/creating.html), is it recommended to follow this procedure even if my wear app has no notifications in it? My project basically consists of modules (common, mobile, and wear) which runs perfectly well whenever I run either the mobile or wear module on the according virtual emulator.
Thanks a bunch!
P.S. Could anybody link me to the Android Wear app on Google Play? I can't seem to find it.
You should still follow the instruction set within the link you have referenced.
Link to wear app on the playstore: https://play.google.com/store/apps/details?id=com.google.android.wearable.app

Android Wear project - with an existing Android project

I have an existing Android app (for 4.2) written using Eclipse.
I'm exploring the possibility of adding an Android Wear component - there's part of the app which I think could work on a watch.
Reading through the docs at https://developer.android.com/training/building-wearables.html I'm unsure of what I'd need to do in order to integrate Wear into my existing project.
For example, under prerequisites it says Android Studio. Does that mean I'd need to migrate my Eclipse solution into Android Studio? Or can I build the Wear component independently?
Essentially, I'm just hoping to hear from someone who has added a Wear component to their existing Android solution so I can understand the basics of what's involved.
Android Wear is essentially very light application. The basic processing happens on the handheld device. Only user interaction functionalities such as accept, reject etc. is deplyed to the wear. Here also the processing is carried on by the handheld device.
So yes, you can include Wear to your project if it adds any value.

Integrating Android Wear

If I want to integrate Android Wear into my app, do I need to rewrite the whole app for the Wear Device or can the App on the wear device use the SharedPrefs, functions and so on from the "normal" Device?
Is there a good tutorial for that?
You should consider app for Android Wear device as a separate app (it's inside separate apk bundled in parent apk i.e actual Android app) that communicates with your master Android app on the device. It's run directly on the wearable device and does not have direct access to things like SharedPreferences. Of course you can implement such access using Data Layer API.
I'd recommend you to start from Android Wear official developer guide: https://developer.android.com/training/building-wearables.html

Android Studio (wear + mobile) app in same project

I would like my android app to work in android wear too. I'm using android studio as IDE.
So what do I do for my app to work in android wear? Do I create another project? If so, will it share the same layouts and classes or will it be a whole other app? I mean, do I need to create two different apps for mobile and wear?
You need use Android Studio creates a new project with two modules, mobile and wear. You now have a project for both your handheld and wearable apps that you can create activities, services, custom layouts, and much more in. On the handheld app, you do most of the heavy lifting, such as network communications, intensive processing, or tasks that require long amounts of user interaction. When these are done, you usually notify the wearable of the results through notifications or by syncing and sending data to the wearable.
For more details, please refer to here.
Select and Go with the android wear activity and in the next window showing Configure your project, Check the Pair with Empty Phone App then it will automatically configure it for android phone and wear.
if you create a wear project, it automatically create "app" and "wear" modules. when you assemble, the wear APK gets embedded in the app APK. that's how it works.
old) In older versions of Android Studio you could select the different platforms for which a module was required during creation of the project.
new) In the current versions of Android Studio you have to just one platform and add the modules for additional platforms after creation of the project.
old)
new)

Categories

Resources