0% found this document useful (0 votes)
65 views40 pages

ESE 343/543 Mobile Cloud Computing: Shan Lin Lab 12 - Android Wear Programming

This document provides an overview of Wear OS (formerly Android Wear), including its core features and design principles for developing apps. It discusses how Wear OS is optimized for smartwatches and emphasizes quick interactions. The document also outlines best practices for designing glanceable interfaces, focusing on core functionality, and updating content in ambient mode while preserving battery life.

Uploaded by

Vincent Han
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views40 pages

ESE 343/543 Mobile Cloud Computing: Shan Lin Lab 12 - Android Wear Programming

This document provides an overview of Wear OS (formerly Android Wear), including its core features and design principles for developing apps. It discusses how Wear OS is optimized for smartwatches and emphasizes quick interactions. The document also outlines best practices for designing glanceable interfaces, focusing on core functionality, and updating content in ambient mode while preserving battery life.

Uploaded by

Vincent Han
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 40

ESE 343/543

Mobile Cloud Computing


Shan Lin
Lab 12 – Android Wear Programming
Wear OS Overview
• Wear OS by Google, formerly Android Wear, is a lightweight platfo
rm that connects to the wearer’s body and provides the right inf
ormation at the right time. Wear makes smartwatches into glanceab
le standalone devices so users can stay connected online and comp
lete tasks quickly, while leaving their phones in their pockets.
• Wear OS is based on Android and is optimized for the wrist. If yo
u have developed for Android, then features such as apps, notific
ations, and Actions on Google may be familiar to you.
• In addition, Wear OS offers new development options such as watch
faces.
Creative vision
Timely
• Wear OS is designed around the core actions of suggest a
nd demand. Wearables provide useful glanceable informati
on on your wrist in real time, allowing users to be more
connected to both the online and real worlds.
Glanceable
• Keep interfaces uncluttered and easy to read.
• Organize information using a clear information hierarchy
.
Easy to tap
• Make sure your tap targets are well-spaced and easy to t
ap.
• Avoid relying on a large amount of user input to use the
app.
Time-saving
• Create efficient flows that help users complete tasks qu
ickly. Avoid creating complex experiences that rely on m
ultiple steps to get a task done.
Designing for watches
• When designing apps for smartwatches, focus on use cases that make sense for the watch environme
nt. Watches allow users to get information at a glance, such as the arrival of the next bus, and
to act quickly, like responding to an instant message.

• The watch interface presents unique usage opportunities that are not available on traditional mo
bile devices, including:

• Easy access (with a flick of the wrist)


• Input enabled by a physical body connection (through sensors, motion detection, and buzzing)

• The watch also comes with limitations:

• Smaller screen space


• Less information density
• Limited battery life
• Consider both the capabilities and limitations of the platform when designing apps for watches.
Focus on core functionality
• Wear OS apps should be designed to support your app’s c
ore functionality. Don’t include unnecessary features,
actions, or content in your app’s watch UI.
• For example:
• An email app for Wear OS should focus on reading message
s and sending replies. It shouldn’t include options for
adding attachments or editing recipients.
• A calendar app for Wear OS should allow users to check a
ttendee availability, read event summaries, and accept i
nvites. It shouldn’t provide the option to create or ed
it events.
Test designs
App examples
• Material design for Wear OS helps you design engaging ap
p experiences. Below are a few illustrated examples of W
ear OS apps that follow the principles described in this
guide.
Build Wear OS apps
• Sample codes from Google.
• Multiple samples showing best practices in app and watch face d
evelopment on Wear OS.
• https://github.com/android/wear-os-samples
• Wear OS by Google developer’s guide
• https://developer.android.com/wear
Android AlwaysOn Sample
• Some Wear OS apps are constantly visible to the user.
• Wear OS devices running Android version 5.1 or higher allow apps to remain in the
foreground while saving battery power.
• Wear OS apps can control what's displayed on the watch while the watch is in a lo
w-power (ambient) mode.
• A watch transitions from interactive mode to ambient mode when the watch is idle o
n an activity or when a user covers the screen with their palm.
• Wear apps that run in both the ambient and interactive modes are called always-on
apps.
• Such apps enable users who are jogging to glance at their watch for the distance c
overed and time elapsed. Some users record shopping lists and can quickly see the
items on a list as they shop.
• Making an app constantly visible has an impact on battery life, so you should care
fully consider that impact when adding this feature to your app.
• Refer to the following related resources:
• AlwaysOn sample
• https://github.com/android/wear-os-samples/tree/master/AlwaysOn
Configure your project
• To support ambient mode, you must update your Android SD
K and configure your development project. Follow these s
teps to make the necessary changes:
• Create or update your project based on the configurations on th
e Creating and Running a Wearable App page.
• https://developer.android.com/training/wearables/apps/creating
• Add the WAKE_LOCK permission to the Android Manifest file:
Ambient mode using the AmbientModeSupport cla
ss
• Using the AmbientModeSupport class to support ambient mo
de enables you to benefit from:
• The Activity subclasses in the Android Support Library, such as
FragmentActivity; functionality for fragments is available
• Architecture components, which are lifecycle aware
• Better support for Google Sign-In
• To use the AmbientModeSupport class, you extend one of t
he FragmentActivity subclasses or the FragmentActivity i
tself and implement a provider interface, which in turn
can be used to listen for ambient mode updates.
AmbientModeSupport class
• The following describes the general use of the AmbientMo
deSupport class:
1. Create a subclass of one of the FragmentActivity classes.
2. Implement the AmbientCallbackProvider interface, as in the ex
ample below. Override the getAmbientCallback() method to prov
ide the callbacks needed for reacting to ambient events from
the Android system. In Step 4, we will create the custom call
back class.
3. In the onCreate() method, enable Ambient mode by calling Ambien
tModeSupport.attach(FragmentActivity). This method returns an Ambie
ntModeSupport.AmbientController. The controller allows you to check
the ambient state outside of the callbacks; you may want to keep a
reference to the AmbientModeSupport.AmbientController object:
4. Create an inner class that extends the AmbientCallback
class in order to act on ambient events. This class becom
es the object returned from the method you created in Ste
p 2:
Handle transitions between modes
• If the user does not interact with your app for a period of time while
it is displayed, or if the user covers the screen with their palm, the
system switches the activity to ambient mode. 
• After the app switches to ambient mode, update the activity UI to a mor
e basic layout to reduce power consumption. You should use a black back
ground with minimal white graphics and text. To ease a user into the tr
ansition from interactive to ambient mode, try to maintain similar plac
ement of items on the screen.
• Note that when your app runs on a device without a hardware button, pal
ming the screen does not switch an app into ambient mode. Rather, it ca
uses the app to exit and the home screen to appear. This behavior is in
tended to ensure that users can exit apps gracefully. However, these de
vices still go to ambient mode when the screen times out.
• When the activity switches to ambient mode, the system c
alls the onEnterAmbient() method in your wearable activi
ty.
• Change the text color to white and disable anti-aliasing
after the system switches to ambient mode:
• When the user taps the screen or brings up their wrist,
the activity switches from ambient mode to interactive m
ode. The system calls the onExitAmbient() method. Overri
de this method to update the UI layout so that your app
displays in a full-color, interactive state.
Update content in ambient mode
1. Ambient mode allows you to update the screen with new i
nformation for the user, but you must carefully balance
display updates against the battery life. You should st
rongly consider only overriding the onUpdateAmbient() m
ethod to update the screen once a minute in ambient mod
e.
2. If your app requires more frequent updates, take into c
onsideration that there is a trade-off between battery
life and the frequency of updates. To realize battery s
avings, updates should be no more than once every 10 se
conds. In practice, however, you should update your app
less frequently than that.
1. onUpdateAmbient( )
• In order to preserve battery power, most Wear apps shoul
d not frequently update the screen while in ambient mode
. We recommend designing your app to update the screen o
nce per minute while in this mode. The system provides a
callback method, onUpdateAmbient(), that allows you to u
pdate the screen at this recommended frequency.
2. AlarmManager
• It is possible, though not recommended, to update a Wear app in ambient mod
e more frequently than once per minute. For apps that do require more frequ
ent updates, you can use an AlarmManager object to wake the processor and u
pdate the screen more frequently.

• To implement an alarm that updates content more frequently in ambient mode,


follow these steps:

a) Prepare the alarm manager.


b) Set the frequency of the updates.
c) Schedule the next update when the activity switches to ambient mode or is currently
in ambient mode.
d) Cancel the alarm when the activity switches to interactive mode or the activity is s
topped
a) Prepare the alarm manager
• The alarm manager launches a pending intent that updates
the screen and schedules the next alarm. The following e
xample shows how to declare the alarm manager and the pe
nding intent in the onCreate() method of your activity:
a) Prepare the alarm manager
• The alarm manager launches a pending intent that updates
the screen and schedules the next alarm. The following e
xample shows how to declare the alarm manager and the pe
nding intent in the onCreate() method of your activity:
• Now we must register and unregister the broadcast receiv
er in onResume() and onPause():
b) Update screen and schedule data u
pdates
• In this example activity, the alarm manager triggers eve
ry 20 seconds in ambient mode. When the timer ticks, the
alarm triggers the intent to update the screen and then
sets the delay for the next update.
c) Schedule the next alarm
• Schedule the alarm to update the screen when the activit
y is entering ambient mode or when the activity is alrea
dy in ambient mode by overriding the onEnterAmbient() me
thod and the onUpdateAmbient() method:
d) Cancel the alarm
• When the device switches to interactive mode, cancel the
alarm in the onExitAmbient() method:

• When the device switches to interactive mode, cancel the


alarm in the onExitAmbient() method:
Screenshots of the app
Assignment 12
• Finish lab 12.
• Get familiar with Android Wear programming.

You might also like