注:本文内容来自:https://developer.android.com/training/wearables/apps/index.html
翻译水平有限,如有疏漏,欢迎批评指教。
译:山人
创建可穿戴设备应用
Creating Wearable Apps
Wearable apps run directly on the device, giving you access to hardware such as sensors and the GPU. They are fundamentally the same as apps built for other devices using the Android SDK, but differ greatly in design and usability and the amount of functionality provided. These are the main differences between handheld and wearable apps:
可穿戴设备应用直接运行在设备上,允许你访问诸如传感器和GPU之类的硬件。它们本质上与运行在其他设备上并且使用Android SDK的应用相同,但是在设计、可用性与功能提供的数量上有很大的不同。下面是手持设备与可穿戴设备主要的区别:
- Wearable apps are relatively small in size and functionality compared to handheld apps. They contain only what makes sense on the wearable, which is usually a small subset of the corresponding handheld app. In general, you should carry out operations on the handheld when possible and send the results to the wearable.
可穿戴设备应用拥有比手持设备应用更小的尺寸和更少的功能。他们只包含可穿戴设备的创造理念,通常是相当于手持设备应用更小的子集。一般而言,你应当尽可能在手持设备上操作,并将结果发送到可穿戴设备之上。
- Users don‘t download apps directly onto the wearable. Instead, you bundle the wearable app inside the handheld app. When users install the handheld app, the system automatically installs the wearable app. However, for development purposes, you can still install the wearable app directly to the wearable.
用户不直接在可穿戴设备上下载应用。作为替代,你将在手持设备应用里绑定可穿戴设备应用。当用户安装了手持设备应用,系统自动在可穿戴设备里安装应用。然而,为了开发应用,你也可以直接安装到可穿戴设备应用之上。
- Wearable apps can access much of the standard Android APIs, but don‘t support the following APIs:
可穿戴设备应用可以访问更多标准Android APIs,除了以下APIs:
You can check if a wearable supports a feature by calling hasSystemFeature()
before trying to use an API.
你可以在使用一个API之前,调用hasSystemFeature()检查可穿戴设备是否支持该功能。
To conserve power on a wearable device, you can enable ambient mode for your Wear app. Devices transition from interactive to ambient mode when the user is idle on an activity or when the user covers the screen with their palm. Wearable apps that can transition into ambient mode are called always-on apps. The following describes the two modes of operation for always-on apps:
为了保证可穿戴设备的电量,你可以使你的Wear App适应环境。当用户的一个activity空闲时,或用户用手掌转变屏幕时,设备从与环境的交互转变模式。能够转变到环境模式的Wearable apps被always-on的应用调用。