- The Android Game Developer's Handbook
- Avisekhar Roy
- 692字
- 2021-07-14 10:28:58
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:
- Select Phone and Tablet and select API 9: Android 2.3 (Gingerbread) under Minimum SDK.
- Select Wear, and select API 20: Android 4.4 (KitKat Wear) under Minimum SDK.
- In the first Add an Activity window, add a blank activity for
mobile
. - 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.
- 微服務(wù)設(shè)計(jì)(第2版)
- Android Wearable Programming
- 數(shù)字媒體應(yīng)用教程
- LabVIEW入門(mén)與實(shí)戰(zhàn)開(kāi)發(fā)100例
- Production Ready OpenStack:Recipes for Successful Environments
- 青少年學(xué)Python(第1冊(cè))
- PHP 7+MySQL 8動(dòng)態(tài)網(wǎng)站開(kāi)發(fā)從入門(mén)到精通(視頻教學(xué)版)
- Unity 2D Game Development Cookbook
- Keras深度學(xué)習(xí)實(shí)戰(zhàn)
- Modern C++ Programming Cookbook
- Hands-On JavaScript for Python Developers
- Learning Jakarta Struts 1.2: a concise and practical tutorial
- Machine Learning for OpenCV
- 計(jì)算語(yǔ)言學(xué)導(dǎo)論
- R語(yǔ)言數(shù)據(jù)分析從入門(mén)到實(shí)戰(zhàn)