Development insights on Android watches

Wearable games run directly on the wearable device, giving the developer access to low-level hardware such as sensors, activities, services, and more, right on the wearable. A companion handheld game that contains the wearable app is also required when the developer wants to publish to the Google Play Store. Wearables don't support the Google Play Store, so users download the companion handheld game, which automatically pushes the wearable game to the wearable. The handheld game is also useful for doing heavy processing, network actions, or other work and sending the results to the wearable.

To develop games on Android wearables, there are some technical steps to be followed. This is not general Android game development:

  • The Android SDK tool has to be updated to version 23.0 or higher
  • The Android platform support within the SDK has to be updated with Android 4.4.2 (API 20) or higher
  • An Android wearable device or emulator is required for development

Creating and setting up a wearable application

This can be done as follows:

Select New Project in Android Studio. In the Configure Project window, enter a name for the application and a package name. In the Form Factors window, perform the following steps:

  1. Select Phone and Tablet and select API 9: Android 2.3 (Gingerbread) under Minimum SDK.
  2. Select Wear, and select API 20: Android 4.4 (KitKat Wear) under Minimum SDK.
  3. In the first Add an Activity window, add a blank activity for mobile.
  4. In the second Add an Activity window, add a blank activity for wear.

When the wizard completes, Android Studio creates a new project with two modules, mobile and wear. Developers now have a project for both their handheld and wearable apps for which they can create activities, services, and custom layouts. The handheld app does most of the heavy lifting, such as network communications, intensive processing, or tasks that require long amounts of user interaction. When the app completes these operations, the application should notify the wearable of the results through notifications or by syncing and sending data to the wearable.

Note

The wear module also contains a Hello World activity that uses a WatchViewStub. This class inflates a layout based on whether the device's screen is round or square. The WatchViewStub class is one of the UI widgets that the wearable support library provides.

Including the correct libraries in the project

There is a lot of library support for Android apps/games. Every developer needs to identify their correct requirements to include the correct libraries.

The following is a list of a few useful libraries for game development on wearable devices:

  • Notifications: The Android v4 support library (or v13, which includes v4) contains the APIs to extend the existing notifications on handhelds to support wearables. For notifications that appear only on the wearable (meaning, they are issued by an app that runs on the wearable), the developer can just use the standard framework APIs (API level 20) on the wearable, and remove the support library dependency in the mobile module of the game or application.
  • Wearable Data Layer: To sync and send data between wearables and handhelds with the Wearable Data Layer APIs, developers need the latest version of Google Play services. If developers are not using these APIs, remove the dependency from both modules.
  • Wearable UI support library: This is an unofficial library that includes UI widgets designed for wearables. The Android platform encourages developers to use them in applications, because they exemplify best practices, and yet they can change at any time. However, if the libraries are updated, the applications won't break, since they are compiled into the project. To get new features from an updated library, developers just need to statically link the new version, and update the application accordingly. This library is only applicable if a developer creates wearable apps.

Hardware compatibility issues with Android versions

Now let's have another look at the absolute minimum hardware requirements, as we already know that Android is not compatible with ARM v4 processors, and Android 4.0+ requires ARM v7 or higher. Android wearables run on Android 4.4 or higher. So the developer must support ARM v7 onwards.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.94.190