This is second part of our tour around Android platforms. In the previous episode, we shared the most important requirements outlined by Google for Android TV apps. Now we are going to focus on Wear apps. What do you have to know before you start developing for Android Wear devices?

Just like with Android TV projects, Android Wear allows you to keep the same structure of code that you use in your mobile projects. Unlike in Android TV, you are able to create different types of wearable applications. The type depends on the capabilities of your watch application.This mean that your watch app can be dependent on your phone app or completely standalone. See the Standalone or dependent apps section.

Let’s take a look at the prerequisites which you should know before you start working on a project.

Distribution of Wear apps

Since Google Announced Wear 2.0, we have two options of distributing our wear applications. The standard of distribution for Wear 1.0 apps was embedding a watch app inside a mobile app. When a user installed an application on their phone, and a compatible Wear application existed in the Play Store, the Wear version would be automatically installed on their Wear 1.0 device.

In terms of distribution on Wear 2.0 you must provide two apk files: one for mobile and one for Wear devices. To do this you must use the Multi-APK delivery method. In this case the user only gets a notification about an application being available on their watch device after they have installed it on their mobile device.

Caution: When you build a Wear 2.0 app that works with a mobile app, remember to use the same key to sign both applications.

Preparing the project

You have to consider which devices you want to support. All devices running on Wear 2.0 use the API level 25 (Android 7.1.1). If you want support both Wear versions, the minimum and target API level must be 23 (Android 6.0).

If you are using existing code, remember to update your gradle build and add metadata that indicate whether your app is standalone or not. In the Android Manifest file ensure that the uses-feature tag is defined (android:name="android.hardware.type.watch"). Otherwise the app won’t be available for Wear devices.

See more.

Standalone and dependent apps

We mentioned before that there are two types of wearable applications. They indicate whether your watch app is a standalone app, which means that your app doesn't require a phone-side Android app to operate. Users can use standalone Wear apps without a phone.

Caution: If you create dependent apps, the code can be shared between the Wear app and the phone app. We recommend to separate the code into different modules for the wear and phone apps. Common code can be stored in a shared library (module).

A Wear app can be:

Completely independent from a phone app;

Semi-independent (a phone app is not required and would provide only optional features);

Dependent on a phone app.

If a watch app is completely independent or semi-independent, you must change the value of the metadata element com.google.android.wearable.standalone to true.

Caution: Even if your wearable app depends on a phone app, the watch app can be installed before the phone app. However, if the watch app detects the lacks of the necessary phone app it should prompt the user to install the phone app.

See more.

Requirements and implementation details regarding layouts

We have collected the most relevant usability requirements and tips below. Follow them and you will easily create a transparent and usable application.

Display views correctly on devices with round screens



There are two approaches to resolving this problem: Using BoxInsetLayout - automatically adjust content depending on the shape of the device screen. (From Wear UI library) Provide different layout resources for square and round screen in resources: layout/ - layouts for circular and square screens. layout-round/ and layout-notround/ specific to the shape of screen. Vertical item list WearableRecyclerView and RecyclerView - Use WearableRecyclerView for long lists of simple items (e.g. contacts). Each item might include a short string with an icon. Use RecyclerView or ListView for short lists of items. You can adjust WearableRecyclerView to create a curved layout for scrollable items. (How to set up a curved layout) Showing confirmations It is recommend that confirmations displayed in Android Wear apps use the whole screen. Automatic confirmation timers let users cancel an action they just performed. The user has the option to cancel an action until the timer finishes. Your app gets notified if the user cancels the action and when the timer expires.



A confirmation timer. Show confirmation animations Use ConfirmationActivity to show a confirmation animation when the user completes an action in your app. Use additional intent data to specify the animation type: SUCCESS_ANIMATION FAILURE_ANIMATION OPEN_ON_PHONE_ANIMATION



A confirmation animation Exiting Activities Wearable devices don’t have a back button. Therefore, the user can exit the app by swiping from left to right. (The power button returns the user to the watch face - home screen). If the app has horizontal scrolling, users exit it by navigating to the edge of the content and swiping from left to right. (We recommend not to use horizontal lists etc.) Activities automatically support swipe-to-dismiss. Wrap the fragment view in a SwipeDismissFrameLayout object. In some cases, such as in views containing a map, swiping from left to right wouldn’t work well. Solutions: If you don’t have many activities, use the power button to dismiss the app and return to the watch face screen (home screen). Wrap the view in a SwipeDismissFrameLayout object which supports edge swiping. Disabling swipe-to-dismiss generally is not recommended. (set the android:windowSwipeToDismiss attribute to false) Navigation and Actions The navigation drawer helps users navigate apps that have many views. Available as a single page or as multiple pages. The Action Drawer provides easy access to common actions in your app.



Single and multi page navigation drawer. The power button supports extra physical states. You can handle a multi-function button press by implementing the onKeyDown method. Be aware that some Android Wear devices support rotary input, such as a rotating the side button. When the user turns the button, your app's current view should scroll up or down. You can use wrist gestures (Flick wrist in/out) for: Scrolling element lists (notification lists). Navigating through vertical screens. (If you are holding a cup of hot coffee - Don’t do this :D)

See the last part about Android Auto for conclusions and a comparison of all three Android platforms.

See also

- Part 1 about Android TV

- Part 3 about Android Auto

Reference: