SlideShare a Scribd company logo
1 of 68
Introduction to Android Wear
Eng. Emanuele De Bernardi – Politecnico di Milano
emanuele.debernardi@polimi.it
What is Android Wear?
2
A version of Android OS
designed by Google for
smartwatches and other
wearables devices
3
What is Android Wear?
 working with mobile phones
Android 4.3 or newer iOS 8.2 or newer
4
What is Android Wear?
 Visualize notifications
5
What is Android Wear?
 Native Apps on Wear
6
What is Android Wear?
 Requires Android 4.3 or iOS 8.2 and above devices
 Latest Google Play Services and Android Wear app from
Google Play installed on smartphone
 Internet and connectivity over Bluetooth from paired
device
 Limited function when the connection with smartphone is
lost
7
Android Wear vs Android Wear 2.0
 New revisited interface based on latest version of Material
Design
 Native apps
 Google Assistant support
 Better UI interaction
 Expanded notifications and Inline Actions
8
Getting started – install SDK
 Install Android Wear SDK Tools from Android Studio
 Latest Android Studio version from
https://developer.android.com/studio/index.html
 Android Wear ARM EABI v7a System Image
 Android Support Library updated
Gettingstarted–install
theemulatorstep1
9
 Select the AVD Manager
 Create the Wearable Virtual Device
10
Gettingstarted–install
theemulatorstep2
11
Gettingstarted–install
theemulatorstep3
 Select the preferred Wearable Hardware
12
Gettingstarted–install
theemulatorstep4
 Select the System Image
13
Gettingstarted–install
theemulatorstep5
 Configure the Android Virtual Device (AVD)
14
Gettingstarted–install
theemulatorstep6
 Starts the Wearable emulator from Your Virtual
Device window
Run it!
15
Gettingstarted–install
theemulatorstep7
 Just play with it!
Wear apps development
 Simple
 Launched automatically
 Glanceable
 Work like a personal butler
 Built oround micro-interactions
 Very low user interactions
17
Example: User Interaction
17
Okay Google, set a timer for
five minutes
Android Wear Interactions
 Two ways of interactions
 Extension of an existing Android App notifications to work
better on Android Wear (existing notifications on phone that
appears also on Wear)
 Standalone Android Wear native app
18
Android Notifications
 Messages you can display to the user outside of your
application’s normal UI
19
Notifications in the notification area
Notifications design considerations
 Important part of the
Android user interface
 New own design features
added with the Material
Design occurrence
20
Notifications in the notification drawer
Build a Notification in Android
 You have to specify the UI information and actions for a
notification in a NotificationCompat.Builder object
 Call NotificationCompat.Builder.build() which returns a
Notification object containing your specifications
 To issue the notification, pass the Notification object to the
system by calling NotificationManager.notify()
21
Build a Notification in Android:
Contents and Settings
 A Notification object must contains
 A small icon set by setSmallIcon()
 A title, set by setContentTitle()
 Detail text, set by setContentText()
 Call The NotificationManager service to notify the event
22
Build a Notification in Android:
Actions
 Optional functions added to NotificationCompat.Builder
 An action allows user to go directly from the notification to an
Activity in the application
 A Notification can provide multiple actions
 Always define the action that’s triggered when the user clicks the
notification, opening a a binded Activity in your appliocation
 Add buttons to the notification that performs additional actions
(without entering in the application to perform some tasks - i.e.,
snoozing an alarm or respond directely to a text message)
23
Build a Notification in Android:
Actions
 Inside a Notification, the action itself is defined by a
PendingIntent containing an Intent (see Intents slides)
that starts an Activity in your application
24
Explicit Intent
for an Activity
StackBuilder object
that contains a back
stack for the started
Activity to the top of
the stack
Action defined by a
PendingIntent. It is added to
the NotificationCompat.Builder
Build a Notification in Android:
Expanded View
 Create a NotificationCompat.Builder object with the
normal view
 call Build.setStyle() with an expanded layout object as its
argument
25
Moves events into the
expanded layout
Set the expanded layout
object into the notification
object
 You should avoid making a new notification when you need to issue a
Notification multime times for the same type of event
 Consider updating a previous Notification changing some of its values
or by adding to it, or both (i.e., Gmail notification when new emails
have arrived by increasing its count of unreaded messages by adding
a summary of each email to the notification)
26
The same
NotificationCompat.Builder
defined previously
Starts of a loop that processes
data and then notifies the user
Use the same id to update the
already existing notification
Build a Notification in Android:
Update
 By Android OS when the user clicks on Clear All (if the
notification can be cleared and not locked by Java code)
 By calling setAutoCancel(true) in NotificationCompat.Builder
when the user clicks on the notification
 By calling cancel() for a specific notification ID deleting also
the ongoing notifications
 By calling cancelAll() removing all of the notification
previously issued
Build a Notification in Android:
Remove
 Respond directely to text messages or update task lists from the
notification dialog (from Android 7.0 - API level 24)
Replying to notifications
 Create an instance of RemoteInput.Builder that you can
add to your notification action.
Adding inline reply actions 1/3
Key for the
string input
that’s delivered
 Attach the remote input object to an action using
addRemoteInput()
Adding inline reply actions 2/3
Create the
reply action
and add the
remote input
 Apply the action to a notification and issue the notification
Adding inline reply actions 3/3
Build the
notification and
add the action
Issue the
notification
Adding Wearable Features to
Notifications
32
 Use the same structure to build the notification in the current
Android project
 Wearable API provided to extends notifications with new features
and personalizations for Wear 2.0
 If the Wearable device is connected, the notification is visualized
Creating a Notification for Wearables
33
 Both the watch and the phone can be sources of notification
 Use the NotificationCompat.Builder class to create the
notification
 Import the necessary packages in the build.gradle
 Import the necessary classes from the support
library
Wearable extension: Notification
Builder
34
 Create an instance of NotificationCompat.Builder
 Issue the notification by passing the Notification object with a
notification ID to notify()
 When the notification appears on a handled device, it appears
also on connected Android Wearable
Wearable extension: Expanded
notifications
35
 Provide substantial additional content and actions for each
notification
 Each expanded notification follows Material Design for Android
Wear 2.0 gets an app-like experience
 The user can view the notification on Wearable when it is
generated by an app on the paired phone and bridged to Wear
Wearable extension: Expanded
notifications
36
 Include additional content and actions for a notification choosing the
level of detail that the app’s notifications will provide
 Adding additional content
To show additional text in the expanded notification,
use BigTextStyle.
To add images in expanded notification, use
BigPictureStyle. To add more than one image in
the expanded Notification use addPage() method
along with the BigPictureStyle
 Primary action
The expanded notificationwill contain on primary
action, which is the first action in the notification
unless a different action is specified using
setContentAction()
 Additional actions
To specify additional actions, use addAction() or
addActions(). The action drawer og the expanded
notification contains all available actions
Wearable extension: Additional
Actions
37
 Is possible to add other actions by passing a PendingIntent to the
setActions() method
 Example: same type of previous notification with an action to view the
event location on a map
On smartphone the
action appears as an
additional button
attached to the
notification
On Wearable the
action appears in the
expanded
notification after the
context text
Wearable extension: Inline Actions
38
 Allows users to take actions on a notification from within the notification
stream card
 Appears as an additional button displayed ad the bottom of the
notification
 Recommended for cases in which users are likely to take an action on a
notification after viewing the contents in the notification card without
going to the expanded notification
Wearable extension: Inline Actions
39
 To display it as an additional button in
the notification, set the
setHintDisplayActionInline(true)
 When a user taps the inline action, the
system invokes the intent specified in
the notification action
Wearable extension: specific features
to a notification
40
 Example remove the app icon from the notification card
 Create an instance of a WearableExtender defining the wearable-specific
options for the notification
 Create an instance of NotificationCompat.Builder defining the desired
properties
 Call extend() on the notification and pass in the Wearable Extension
 Call build()
Wearable only Actions
41
 To set Actions on the wearable different from the smartphone
use WearableExtender.addAction()
 With this method the wearable does not display any other
actions added with
NotificationCompat.Builder.addAction()
 The actions added with WearableExtender.addAction()
appear only on the wearable and not to the smartphone app
Wearable only Actions: Example
42
 Create an action that
supports voice input
only on wearable
device
Class contructor
accepts a string
that the system
uses as the key
for the voice
input
Standalone Wearable apps
43
Standalone Wearable apps
44
 Apps that work independently of a phone app
 User can complete more tasks on a watch without using the phone
 Apps not embedded in a phone APK
Identification and storage
45
 minimum API level 25 (for Wear 2.0), or API level 23 (for Wear 1.0
and 2.0)
 Wear 2.0 requires meta-data element called
com.google.android.wearable.standalone in the Android
Manifest as a child of <application> element
 true: the Wear pp is available on Play Store if the watch is connected
with an iPhone
 Standard storage used for smarpthone APK
 SQLite
 SharedPreferences
 Internal Storage
Custom Notifications
46
 In general notification are created from the phone app and then visualized on
Android Wear, Auto, TV
 To show a notification on a standalone wearable app:
 Display an Activity with a custom layout
 Define properties for the Activity in the Android Manifest defining
• android:exportable = true;
• android:allowEmbedded = true;
• android:taskAffinity = ‘’;
 Create a PendingIntent to call the Notification Activity
 Build a default Notification and call setDisplayIntent() providing the
PendingIntent to call the Activity
 Call the Notification with the notify() method
The UI Library
47
 Insert the UI Library in the build.gradle file
 Major classes:
 BoxInsetLayout: screen shape to box its children views (for round and square
screens)
 ConfirmationActivity: displays cnfirmation animations when user finish an action
 AnimationSet: group of animations
 CircularProgressLayout: progress with a circular timedown timer typically used to
restore an user task
 AlertDialog: Dialog with one, two or three buttons
 ProgressBar: display to the user how far the operation has progressed
 WearableRecyclerView: displaying scrollable lists of items
Creating Custom UIs - Defining
Layouts
48
 Need to be designed with specific constraints
 Wrong approach:
 Best approach:
 BoxInsetLayout: applies different window insets depending on the shape of the
window screen without having views cropped near the edges of round screen
 CurvedLayout: to visualize and manipulate vertical list of items optimized for round
screens
Creating Custom UIs - Lists
49
 Select an item from a set of choices easily
 Extend to the interested Activity the WearableRecyclerView
class to create lists optimized for Wear 2.0
 Recommended for a long list of simple items with a simple icon
and a short string associated (i.e., application launcher, list of
contacts...)
Creating Custom UIs – Curved Layout
50
 Use the WearableRecyclerView extended to the Activity
 Set the setEdgeItemsCenteringEnabled(true) to align the first and the
last elements of the list vertically centered on the screen
 Use the WearableRecyclerView.setLayoutManager() method to set the
elements
 Enabling circular gesture scrolling calling
setCircularScrollingGestureEnabled(true) method
Creating Custom UIs – Showing
confirmation Timers
51
 Usually use the whole screen ensuring that the user can visualize the
confirmation button larger enough to touch it to cancel an action
 Automatic confirmation timers show users an
animated timer that lets them cancel an
action they just performed
 The animations give users visual feedback
when they complete an action
Creating Custom UIs – Showing
confirmation Timers
52
 including the dipendencies in the build.gradle
 Add a CircularProgressLayout element to layout
Creating Custom UIs – Showing
confirmation Timers
53
 Implement the CircularProgressLayout.onTimerFinishedListener
interface in the Activity
Creating Custom UIs – Showing
confirmation Timers
54
 Set the duration of the timer and start it when the user completes an action
 Show the confirmation animations creating an Intent that starts a new
Activity including an EXTRA_ANIMATION_TYPE intent extra and an
EXTRA_MESSAGE string:
 SUCCESS_ANIMATION
 FAILURE_ANIMATION
 OPEN_ON_PHONE_ANIMATION
Creating Custom UIs – Wear
Navigation and Actions
55
 Two tinteractive Drawers designed in Material Design
 Navigation Drawer: switch
between views in the app
• Multi-page navigation
drawer: present the
contents of a navigation
drawer in a single page or
as multiple pages defining
app:navigationStyle=‘’
multipage’’ in the XML
layout
 Action Drawer: easy access to
common actions appearing at
the bottom of the screen using
context-specific user actions
(similar to ActionBar to
smartphone). It peeks when the
user reaches the top or bottom
of the scrolling content
Create a WearableDrawerLayout
56
 Example: declare an interface with a WearableDrawerLayout object as a
root view of the layout supporting the nested scrolling.
The main
content
 To add a multi-page
navigation apply the
attribute
navigationStyle=‘’mult
iPage’’ to the drawer
Initialize the Drawer contents
57
 Initialize the drawers’ lists of items exenting the WearableDrawerAdapter to
populate the navigation drawer contents
 Populate the action
drawer contents in
the layout XML file
using
app:actionMenu
attribute
 Initialize the
contents of the
drawer
Ambient mode
58
 Visualize the current Activity in a low-power mode saving battery
on Wear device
• Update dipendencies
to build.gradle
• Add wearable shared
library
• Add WAKE_LOCK
permission
Ambient mode - handle transitions
59
 If the user covers the screen with their palm, the system switches
the activity to Ambient mode
 Note: by default when the app runs on a device, palming the
screen does not switch an app into Ambient mode causing the
Activity to exit and the home screen to appear
Ambient mode - handle transitions
60
 When the Activity switches to ambient mode, the system calls onEnterAmbient()
method
 When the user taps the screen or brings up the wrist, the Activity switches from Ambient
mode to Interactive mode calling onExitAmbient() method
 Update the information on the screen using onUpdateAmbient() method
 Note: carefully balance display updates to not compromise the battery consumption. To
realize battery savings, updates should be no more than once every 10 seconds. For apps
that have to be updated frequently use an AlarmManager to wake the processor
• Example: change the text color
to white and set the antialias to
false
• Example: change the text color
to green and set the antialias to
true
Multi-function Buttons
61
 Android Wear supports extra physical buttons in addition to power button
 onKeyDown() method
 Note: find a method that searches the number of available buttons on wearable
device
Available set of possible
keycodes that the app can
receive and convert them to a
specific in-app actions
Using Wrist Gestures
62
 Enable quick one-handed interactions with the app when the
touch screen is inconvenient
 Example of use:
 scroll through notifications with one hand while holding a cup of
coffe with the other
 In app for jogging where the navigation through vertical screens
shows the steps, time elapsed
 ...
 To activate them on the Wearable, confirm gestures to turn on by selecting
Settings > Gestures > Wirst Gestures On
Using Wrist Gestures
63
 Curved layout with predefined gestures
 The WaerableRecyclerView class automatically supports wirst
gestures using predefined actions for occurrences when the view
has focus
previous item ReturnSelect an itemNext item
 Using KeyEvents to customize functions defined by user action
 Using KeyEvents The events are delivered to the top Activity that
implements KeyEvent.CallBack that listens the key event related to
the wrist gestures
Using Wrist Gestures
64
 Android Wear 2.0 allows to communicate with a network directly without
access to an Android or iOS phone
Sending and Sync Data
65
 Wearable Data Layer API is used to manage
data between Wear 1.0 and Phone
 DataItem provides data storage with automatic syncing
between the phone and wearable
 Message good for remote procedure calls for one-way
requests or request/response communication model (i.e.,
controlling the media player from wearable)
 Asset for sending bolbs of data conserving Bluetooth
bandwidth (i.e., images) froom phone to wearable
 WearableListenerService when it needed to send data
items (i.e., sensors states) or messages in backround
 DataListener for important data layer events when the
user is actively using the app in foreground
 Channel to transfer large data items (i.e., movies or
music) from phone to wearable
 For more details: https://developer.android.com/training/wearables/data-
layer/index.html
Cloud Messaging
 To send notifications, apps can directely use
Firebase Cloud Messaging (FCM) which replcaes
Google Cloud Messaging (GCM)
 FCM is supported on Wear 2.0
 For more details see: https://firebase.google.com/docs/cloud-
messaging/concept-options
 FMC sends messages to the device by collecting a registration token for it
when the Wear app runs
 By default notifications are shared form a phone app to watch. For
standalone Wear apps FMC could be displayed independentlyThe FMC
message is in JSON format including:
 Notification payload: when a notifiation payload is received by a watch, the data
is displayed to a user directely in the notification stream. When the user tap the
notification, the app is launched
 Data payload: set of custom key/value pairs. The payload is delivered as data to
the Wear app
 Android Wear Online Lessons: http://www.udacity.com
 https://developer.android.com/training/building-wearables.html
 https://developer.android.com/training/wearables/apps/creating.
html
 https://developer.android.com/training/wearables/notifications/no
ti-styles.html
 https://developer.android.com/training/wearables/notifications/co
mpatibility.html
 https://developer.android.com/training/wearables/apps/index.ht
ml
 https://developer.android.com/training/wearables/ui/index.html
References
67
 https://developer.android.com/training/wearables/data-
layer/index.html
References
68

More Related Content

Similar to Introduction to Android Wear

Android Wearables ii
Android Wearables iiAndroid Wearables ii
Android Wearables iiKetan Raval
 
Exercises broadcast receiver,incoming phone call
Exercises broadcast receiver,incoming phone callExercises broadcast receiver,incoming phone call
Exercises broadcast receiver,incoming phone callmaamir farooq
 
Developing for Android Wear - Part 1
Developing for Android Wear - Part 1Developing for Android Wear - Part 1
Developing for Android Wear - Part 1Justin Munger
 
Android Development: Build Android App from Scratch
Android Development: Build Android App from ScratchAndroid Development: Build Android App from Scratch
Android Development: Build Android App from ScratchTaufan Erfiyanto
 
"It's Time" - Android Wear codelab - GDG MeetsU - L'Aquila
"It's Time" - Android Wear codelab - GDG MeetsU - L'Aquila"It's Time" - Android Wear codelab - GDG MeetsU - L'Aquila
"It's Time" - Android Wear codelab - GDG MeetsU - L'AquilaGiuseppe Cerratti
 
MPointInc_AndroidSDK_Documentation
MPointInc_AndroidSDK_DocumentationMPointInc_AndroidSDK_Documentation
MPointInc_AndroidSDK_DocumentationXin Shao
 
Developing for android wear
Developing for android wearDeveloping for android wear
Developing for android wearThomas Oldervoll
 
Implementation of Push Notification in React Native Android app using Firebas...
Implementation of Push Notification in React Native Android app using Firebas...Implementation of Push Notification in React Native Android app using Firebas...
Implementation of Push Notification in React Native Android app using Firebas...naseeb20
 
Complete steps to Integrate Push Notification for Your Cocos2dx App with Push...
Complete steps to Integrate Push Notification for Your Cocos2dx App with Push...Complete steps to Integrate Push Notification for Your Cocos2dx App with Push...
Complete steps to Integrate Push Notification for Your Cocos2dx App with Push...ShepHertz
 
Session #8 adding magic to your app
Session #8  adding magic to your appSession #8  adding magic to your app
Session #8 adding magic to your appVitali Pekelis
 
Android Evolution, AppForum 2014, Brussels, Friedger Müffke
Android Evolution, AppForum 2014, Brussels, Friedger MüffkeAndroid Evolution, AppForum 2014, Brussels, Friedger Müffke
Android Evolution, AppForum 2014, Brussels, Friedger MüffkeFriedger Müffke
 
Android Wear – IO Extended
Android Wear – IO ExtendedAndroid Wear – IO Extended
Android Wear – IO ExtendedDouglas Drumond
 
Android interview questions and answers
Android interview questions and answersAndroid interview questions and answers
Android interview questions and answerskavinilavuG
 

Similar to Introduction to Android Wear (20)

Notification android
Notification androidNotification android
Notification android
 
Android Wearables ii
Android Wearables iiAndroid Wearables ii
Android Wearables ii
 
Exercises broadcast receiver,incoming phone call
Exercises broadcast receiver,incoming phone callExercises broadcast receiver,incoming phone call
Exercises broadcast receiver,incoming phone call
 
Developing for Android Wear - Part 1
Developing for Android Wear - Part 1Developing for Android Wear - Part 1
Developing for Android Wear - Part 1
 
Android action bar and notifications-chapter16
Android action bar and notifications-chapter16Android action bar and notifications-chapter16
Android action bar and notifications-chapter16
 
Android Development: Build Android App from Scratch
Android Development: Build Android App from ScratchAndroid Development: Build Android App from Scratch
Android Development: Build Android App from Scratch
 
"It's Time" - Android Wear codelab - GDG MeetsU - L'Aquila
"It's Time" - Android Wear codelab - GDG MeetsU - L'Aquila"It's Time" - Android Wear codelab - GDG MeetsU - L'Aquila
"It's Time" - Android Wear codelab - GDG MeetsU - L'Aquila
 
Android Wear Development
Android Wear DevelopmentAndroid Wear Development
Android Wear Development
 
MPointInc_AndroidSDK_Documentation
MPointInc_AndroidSDK_DocumentationMPointInc_AndroidSDK_Documentation
MPointInc_AndroidSDK_Documentation
 
Developing for android wear
Developing for android wearDeveloping for android wear
Developing for android wear
 
Intake 37 9
Intake 37 9Intake 37 9
Intake 37 9
 
Intake 38 9
Intake 38 9Intake 38 9
Intake 38 9
 
Implementation of Push Notification in React Native Android app using Firebas...
Implementation of Push Notification in React Native Android app using Firebas...Implementation of Push Notification in React Native Android app using Firebas...
Implementation of Push Notification in React Native Android app using Firebas...
 
Complete steps to Integrate Push Notification for Your Cocos2dx App with Push...
Complete steps to Integrate Push Notification for Your Cocos2dx App with Push...Complete steps to Integrate Push Notification for Your Cocos2dx App with Push...
Complete steps to Integrate Push Notification for Your Cocos2dx App with Push...
 
Session #8 adding magic to your app
Session #8  adding magic to your appSession #8  adding magic to your app
Session #8 adding magic to your app
 
Android Evolution, AppForum 2014, Brussels, Friedger Müffke
Android Evolution, AppForum 2014, Brussels, Friedger MüffkeAndroid Evolution, AppForum 2014, Brussels, Friedger Müffke
Android Evolution, AppForum 2014, Brussels, Friedger Müffke
 
Android Wear – IO Extended
Android Wear – IO ExtendedAndroid Wear – IO Extended
Android Wear – IO Extended
 
Create New Android Activity
Create New Android ActivityCreate New Android Activity
Create New Android Activity
 
Learning Android Part 2/6
Learning Android Part 2/6Learning Android Part 2/6
Learning Android Part 2/6
 
Android interview questions and answers
Android interview questions and answersAndroid interview questions and answers
Android interview questions and answers
 

Recently uploaded

Design Analysis of Alogorithm 1 ppt 2024.pptx
Design Analysis of Alogorithm 1 ppt 2024.pptxDesign Analysis of Alogorithm 1 ppt 2024.pptx
Design Analysis of Alogorithm 1 ppt 2024.pptxrajesshs31r
 
me3493 manufacturing technology unit 1 Part A
me3493 manufacturing technology unit 1 Part Ame3493 manufacturing technology unit 1 Part A
me3493 manufacturing technology unit 1 Part Akarthi keyan
 
sdfsadopkjpiosufoiasdoifjasldkjfl a asldkjflaskdjflkjsdsdf
sdfsadopkjpiosufoiasdoifjasldkjfl a asldkjflaskdjflkjsdsdfsdfsadopkjpiosufoiasdoifjasldkjfl a asldkjflaskdjflkjsdsdf
sdfsadopkjpiosufoiasdoifjasldkjfl a asldkjflaskdjflkjsdsdfJulia Kaye
 
Oracle_PLSQL_basic_tutorial_with_workon_Exercises.ppt
Oracle_PLSQL_basic_tutorial_with_workon_Exercises.pptOracle_PLSQL_basic_tutorial_with_workon_Exercises.ppt
Oracle_PLSQL_basic_tutorial_with_workon_Exercises.pptDheerajKashnyal
 
Graphics Primitives and CG Display Devices
Graphics Primitives and CG Display DevicesGraphics Primitives and CG Display Devices
Graphics Primitives and CG Display DevicesDIPIKA83
 
دليل تجارب الاسفلت المختبرية - Asphalt Experiments Guide Laboratory
دليل تجارب الاسفلت المختبرية - Asphalt Experiments Guide Laboratoryدليل تجارب الاسفلت المختبرية - Asphalt Experiments Guide Laboratory
دليل تجارب الاسفلت المختبرية - Asphalt Experiments Guide LaboratoryBahzad5
 
SATELITE COMMUNICATION UNIT 1 CEC352 REGULATION 2021 PPT BASICS OF SATELITE ....
SATELITE COMMUNICATION UNIT 1 CEC352 REGULATION 2021 PPT BASICS OF SATELITE ....SATELITE COMMUNICATION UNIT 1 CEC352 REGULATION 2021 PPT BASICS OF SATELITE ....
SATELITE COMMUNICATION UNIT 1 CEC352 REGULATION 2021 PPT BASICS OF SATELITE ....santhyamuthu1
 
Gender Bias in Engineer, Honors 203 Project
Gender Bias in Engineer, Honors 203 ProjectGender Bias in Engineer, Honors 203 Project
Gender Bias in Engineer, Honors 203 Projectreemakb03
 
Strategies of Urban Morphologyfor Improving Outdoor Thermal Comfort and Susta...
Strategies of Urban Morphologyfor Improving Outdoor Thermal Comfort and Susta...Strategies of Urban Morphologyfor Improving Outdoor Thermal Comfort and Susta...
Strategies of Urban Morphologyfor Improving Outdoor Thermal Comfort and Susta...amrabdallah9
 
IT3401-WEB ESSENTIALS PRESENTATIONS.pptx
IT3401-WEB ESSENTIALS PRESENTATIONS.pptxIT3401-WEB ESSENTIALS PRESENTATIONS.pptx
IT3401-WEB ESSENTIALS PRESENTATIONS.pptxSAJITHABANUS
 
Quasi-Stochastic Approximation: Algorithm Design Principles with Applications...
Quasi-Stochastic Approximation: Algorithm Design Principles with Applications...Quasi-Stochastic Approximation: Algorithm Design Principles with Applications...
Quasi-Stochastic Approximation: Algorithm Design Principles with Applications...Sean Meyn
 
The relationship between iot and communication technology
The relationship between iot and communication technologyThe relationship between iot and communication technology
The relationship between iot and communication technologyabdulkadirmukarram03
 
ChatGPT-and-Generative-AI-Landscape Working of generative ai search
ChatGPT-and-Generative-AI-Landscape Working of generative ai searchChatGPT-and-Generative-AI-Landscape Working of generative ai search
ChatGPT-and-Generative-AI-Landscape Working of generative ai searchrohitcse52
 
GENERAL CONDITIONS FOR CONTRACTS OF CIVIL ENGINEERING WORKS
GENERAL CONDITIONS  FOR  CONTRACTS OF CIVIL ENGINEERING WORKS GENERAL CONDITIONS  FOR  CONTRACTS OF CIVIL ENGINEERING WORKS
GENERAL CONDITIONS FOR CONTRACTS OF CIVIL ENGINEERING WORKS Bahzad5
 
nvidia AI-gtc 2024 partial slide deck.pptx
nvidia AI-gtc 2024 partial slide deck.pptxnvidia AI-gtc 2024 partial slide deck.pptx
nvidia AI-gtc 2024 partial slide deck.pptxjasonsedano2
 
Phase noise transfer functions.pptx
Phase noise transfer      functions.pptxPhase noise transfer      functions.pptx
Phase noise transfer functions.pptxSaiGouthamSunkara
 
A Seminar on Electric Vehicle Software Simulation
A Seminar on Electric Vehicle Software SimulationA Seminar on Electric Vehicle Software Simulation
A Seminar on Electric Vehicle Software SimulationMohsinKhanA
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHC Sai Kiran
 

Recently uploaded (20)

Design Analysis of Alogorithm 1 ppt 2024.pptx
Design Analysis of Alogorithm 1 ppt 2024.pptxDesign Analysis of Alogorithm 1 ppt 2024.pptx
Design Analysis of Alogorithm 1 ppt 2024.pptx
 
計劃趕得上變化
計劃趕得上變化計劃趕得上變化
計劃趕得上變化
 
me3493 manufacturing technology unit 1 Part A
me3493 manufacturing technology unit 1 Part Ame3493 manufacturing technology unit 1 Part A
me3493 manufacturing technology unit 1 Part A
 
sdfsadopkjpiosufoiasdoifjasldkjfl a asldkjflaskdjflkjsdsdf
sdfsadopkjpiosufoiasdoifjasldkjfl a asldkjflaskdjflkjsdsdfsdfsadopkjpiosufoiasdoifjasldkjfl a asldkjflaskdjflkjsdsdf
sdfsadopkjpiosufoiasdoifjasldkjfl a asldkjflaskdjflkjsdsdf
 
Oracle_PLSQL_basic_tutorial_with_workon_Exercises.ppt
Oracle_PLSQL_basic_tutorial_with_workon_Exercises.pptOracle_PLSQL_basic_tutorial_with_workon_Exercises.ppt
Oracle_PLSQL_basic_tutorial_with_workon_Exercises.ppt
 
Graphics Primitives and CG Display Devices
Graphics Primitives and CG Display DevicesGraphics Primitives and CG Display Devices
Graphics Primitives and CG Display Devices
 
دليل تجارب الاسفلت المختبرية - Asphalt Experiments Guide Laboratory
دليل تجارب الاسفلت المختبرية - Asphalt Experiments Guide Laboratoryدليل تجارب الاسفلت المختبرية - Asphalt Experiments Guide Laboratory
دليل تجارب الاسفلت المختبرية - Asphalt Experiments Guide Laboratory
 
SATELITE COMMUNICATION UNIT 1 CEC352 REGULATION 2021 PPT BASICS OF SATELITE ....
SATELITE COMMUNICATION UNIT 1 CEC352 REGULATION 2021 PPT BASICS OF SATELITE ....SATELITE COMMUNICATION UNIT 1 CEC352 REGULATION 2021 PPT BASICS OF SATELITE ....
SATELITE COMMUNICATION UNIT 1 CEC352 REGULATION 2021 PPT BASICS OF SATELITE ....
 
Gender Bias in Engineer, Honors 203 Project
Gender Bias in Engineer, Honors 203 ProjectGender Bias in Engineer, Honors 203 Project
Gender Bias in Engineer, Honors 203 Project
 
Strategies of Urban Morphologyfor Improving Outdoor Thermal Comfort and Susta...
Strategies of Urban Morphologyfor Improving Outdoor Thermal Comfort and Susta...Strategies of Urban Morphologyfor Improving Outdoor Thermal Comfort and Susta...
Strategies of Urban Morphologyfor Improving Outdoor Thermal Comfort and Susta...
 
IT3401-WEB ESSENTIALS PRESENTATIONS.pptx
IT3401-WEB ESSENTIALS PRESENTATIONS.pptxIT3401-WEB ESSENTIALS PRESENTATIONS.pptx
IT3401-WEB ESSENTIALS PRESENTATIONS.pptx
 
Présentation IIRB 2024 Marine Cordonnier.pdf
Présentation IIRB 2024 Marine Cordonnier.pdfPrésentation IIRB 2024 Marine Cordonnier.pdf
Présentation IIRB 2024 Marine Cordonnier.pdf
 
Quasi-Stochastic Approximation: Algorithm Design Principles with Applications...
Quasi-Stochastic Approximation: Algorithm Design Principles with Applications...Quasi-Stochastic Approximation: Algorithm Design Principles with Applications...
Quasi-Stochastic Approximation: Algorithm Design Principles with Applications...
 
The relationship between iot and communication technology
The relationship between iot and communication technologyThe relationship between iot and communication technology
The relationship between iot and communication technology
 
ChatGPT-and-Generative-AI-Landscape Working of generative ai search
ChatGPT-and-Generative-AI-Landscape Working of generative ai searchChatGPT-and-Generative-AI-Landscape Working of generative ai search
ChatGPT-and-Generative-AI-Landscape Working of generative ai search
 
GENERAL CONDITIONS FOR CONTRACTS OF CIVIL ENGINEERING WORKS
GENERAL CONDITIONS  FOR  CONTRACTS OF CIVIL ENGINEERING WORKS GENERAL CONDITIONS  FOR  CONTRACTS OF CIVIL ENGINEERING WORKS
GENERAL CONDITIONS FOR CONTRACTS OF CIVIL ENGINEERING WORKS
 
nvidia AI-gtc 2024 partial slide deck.pptx
nvidia AI-gtc 2024 partial slide deck.pptxnvidia AI-gtc 2024 partial slide deck.pptx
nvidia AI-gtc 2024 partial slide deck.pptx
 
Phase noise transfer functions.pptx
Phase noise transfer      functions.pptxPhase noise transfer      functions.pptx
Phase noise transfer functions.pptx
 
A Seminar on Electric Vehicle Software Simulation
A Seminar on Electric Vehicle Software SimulationA Seminar on Electric Vehicle Software Simulation
A Seminar on Electric Vehicle Software Simulation
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECH
 

Introduction to Android Wear

  • 1. Introduction to Android Wear Eng. Emanuele De Bernardi – Politecnico di Milano emanuele.debernardi@polimi.it
  • 2. What is Android Wear? 2 A version of Android OS designed by Google for smartwatches and other wearables devices
  • 3. 3 What is Android Wear?  working with mobile phones Android 4.3 or newer iOS 8.2 or newer
  • 4. 4 What is Android Wear?  Visualize notifications
  • 5. 5 What is Android Wear?  Native Apps on Wear
  • 6. 6 What is Android Wear?  Requires Android 4.3 or iOS 8.2 and above devices  Latest Google Play Services and Android Wear app from Google Play installed on smartphone  Internet and connectivity over Bluetooth from paired device  Limited function when the connection with smartphone is lost
  • 7. 7 Android Wear vs Android Wear 2.0  New revisited interface based on latest version of Material Design  Native apps  Google Assistant support  Better UI interaction  Expanded notifications and Inline Actions
  • 8. 8 Getting started – install SDK  Install Android Wear SDK Tools from Android Studio  Latest Android Studio version from https://developer.android.com/studio/index.html  Android Wear ARM EABI v7a System Image  Android Support Library updated
  • 10.  Create the Wearable Virtual Device 10 Gettingstarted–install theemulatorstep2
  • 14. 14 Gettingstarted–install theemulatorstep6  Starts the Wearable emulator from Your Virtual Device window Run it!
  • 16. Wear apps development  Simple  Launched automatically  Glanceable  Work like a personal butler  Built oround micro-interactions  Very low user interactions
  • 17. 17 Example: User Interaction 17 Okay Google, set a timer for five minutes
  • 18. Android Wear Interactions  Two ways of interactions  Extension of an existing Android App notifications to work better on Android Wear (existing notifications on phone that appears also on Wear)  Standalone Android Wear native app 18
  • 19. Android Notifications  Messages you can display to the user outside of your application’s normal UI 19 Notifications in the notification area
  • 20. Notifications design considerations  Important part of the Android user interface  New own design features added with the Material Design occurrence 20 Notifications in the notification drawer
  • 21. Build a Notification in Android  You have to specify the UI information and actions for a notification in a NotificationCompat.Builder object  Call NotificationCompat.Builder.build() which returns a Notification object containing your specifications  To issue the notification, pass the Notification object to the system by calling NotificationManager.notify() 21
  • 22. Build a Notification in Android: Contents and Settings  A Notification object must contains  A small icon set by setSmallIcon()  A title, set by setContentTitle()  Detail text, set by setContentText()  Call The NotificationManager service to notify the event 22
  • 23. Build a Notification in Android: Actions  Optional functions added to NotificationCompat.Builder  An action allows user to go directly from the notification to an Activity in the application  A Notification can provide multiple actions  Always define the action that’s triggered when the user clicks the notification, opening a a binded Activity in your appliocation  Add buttons to the notification that performs additional actions (without entering in the application to perform some tasks - i.e., snoozing an alarm or respond directely to a text message) 23
  • 24. Build a Notification in Android: Actions  Inside a Notification, the action itself is defined by a PendingIntent containing an Intent (see Intents slides) that starts an Activity in your application 24 Explicit Intent for an Activity StackBuilder object that contains a back stack for the started Activity to the top of the stack Action defined by a PendingIntent. It is added to the NotificationCompat.Builder
  • 25. Build a Notification in Android: Expanded View  Create a NotificationCompat.Builder object with the normal view  call Build.setStyle() with an expanded layout object as its argument 25 Moves events into the expanded layout Set the expanded layout object into the notification object
  • 26.  You should avoid making a new notification when you need to issue a Notification multime times for the same type of event  Consider updating a previous Notification changing some of its values or by adding to it, or both (i.e., Gmail notification when new emails have arrived by increasing its count of unreaded messages by adding a summary of each email to the notification) 26 The same NotificationCompat.Builder defined previously Starts of a loop that processes data and then notifies the user Use the same id to update the already existing notification Build a Notification in Android: Update
  • 27.  By Android OS when the user clicks on Clear All (if the notification can be cleared and not locked by Java code)  By calling setAutoCancel(true) in NotificationCompat.Builder when the user clicks on the notification  By calling cancel() for a specific notification ID deleting also the ongoing notifications  By calling cancelAll() removing all of the notification previously issued Build a Notification in Android: Remove
  • 28.  Respond directely to text messages or update task lists from the notification dialog (from Android 7.0 - API level 24) Replying to notifications
  • 29.  Create an instance of RemoteInput.Builder that you can add to your notification action. Adding inline reply actions 1/3 Key for the string input that’s delivered
  • 30.  Attach the remote input object to an action using addRemoteInput() Adding inline reply actions 2/3 Create the reply action and add the remote input
  • 31.  Apply the action to a notification and issue the notification Adding inline reply actions 3/3 Build the notification and add the action Issue the notification
  • 32. Adding Wearable Features to Notifications 32  Use the same structure to build the notification in the current Android project  Wearable API provided to extends notifications with new features and personalizations for Wear 2.0  If the Wearable device is connected, the notification is visualized
  • 33. Creating a Notification for Wearables 33  Both the watch and the phone can be sources of notification  Use the NotificationCompat.Builder class to create the notification  Import the necessary packages in the build.gradle  Import the necessary classes from the support library
  • 34. Wearable extension: Notification Builder 34  Create an instance of NotificationCompat.Builder  Issue the notification by passing the Notification object with a notification ID to notify()  When the notification appears on a handled device, it appears also on connected Android Wearable
  • 35. Wearable extension: Expanded notifications 35  Provide substantial additional content and actions for each notification  Each expanded notification follows Material Design for Android Wear 2.0 gets an app-like experience  The user can view the notification on Wearable when it is generated by an app on the paired phone and bridged to Wear
  • 36. Wearable extension: Expanded notifications 36  Include additional content and actions for a notification choosing the level of detail that the app’s notifications will provide  Adding additional content To show additional text in the expanded notification, use BigTextStyle. To add images in expanded notification, use BigPictureStyle. To add more than one image in the expanded Notification use addPage() method along with the BigPictureStyle  Primary action The expanded notificationwill contain on primary action, which is the first action in the notification unless a different action is specified using setContentAction()  Additional actions To specify additional actions, use addAction() or addActions(). The action drawer og the expanded notification contains all available actions
  • 37. Wearable extension: Additional Actions 37  Is possible to add other actions by passing a PendingIntent to the setActions() method  Example: same type of previous notification with an action to view the event location on a map On smartphone the action appears as an additional button attached to the notification On Wearable the action appears in the expanded notification after the context text
  • 38. Wearable extension: Inline Actions 38  Allows users to take actions on a notification from within the notification stream card  Appears as an additional button displayed ad the bottom of the notification  Recommended for cases in which users are likely to take an action on a notification after viewing the contents in the notification card without going to the expanded notification
  • 39. Wearable extension: Inline Actions 39  To display it as an additional button in the notification, set the setHintDisplayActionInline(true)  When a user taps the inline action, the system invokes the intent specified in the notification action
  • 40. Wearable extension: specific features to a notification 40  Example remove the app icon from the notification card  Create an instance of a WearableExtender defining the wearable-specific options for the notification  Create an instance of NotificationCompat.Builder defining the desired properties  Call extend() on the notification and pass in the Wearable Extension  Call build()
  • 41. Wearable only Actions 41  To set Actions on the wearable different from the smartphone use WearableExtender.addAction()  With this method the wearable does not display any other actions added with NotificationCompat.Builder.addAction()  The actions added with WearableExtender.addAction() appear only on the wearable and not to the smartphone app
  • 42. Wearable only Actions: Example 42  Create an action that supports voice input only on wearable device Class contructor accepts a string that the system uses as the key for the voice input
  • 44. Standalone Wearable apps 44  Apps that work independently of a phone app  User can complete more tasks on a watch without using the phone  Apps not embedded in a phone APK
  • 45. Identification and storage 45  minimum API level 25 (for Wear 2.0), or API level 23 (for Wear 1.0 and 2.0)  Wear 2.0 requires meta-data element called com.google.android.wearable.standalone in the Android Manifest as a child of <application> element  true: the Wear pp is available on Play Store if the watch is connected with an iPhone  Standard storage used for smarpthone APK  SQLite  SharedPreferences  Internal Storage
  • 46. Custom Notifications 46  In general notification are created from the phone app and then visualized on Android Wear, Auto, TV  To show a notification on a standalone wearable app:  Display an Activity with a custom layout  Define properties for the Activity in the Android Manifest defining • android:exportable = true; • android:allowEmbedded = true; • android:taskAffinity = ‘’;  Create a PendingIntent to call the Notification Activity  Build a default Notification and call setDisplayIntent() providing the PendingIntent to call the Activity  Call the Notification with the notify() method
  • 47. The UI Library 47  Insert the UI Library in the build.gradle file  Major classes:  BoxInsetLayout: screen shape to box its children views (for round and square screens)  ConfirmationActivity: displays cnfirmation animations when user finish an action  AnimationSet: group of animations  CircularProgressLayout: progress with a circular timedown timer typically used to restore an user task  AlertDialog: Dialog with one, two or three buttons  ProgressBar: display to the user how far the operation has progressed  WearableRecyclerView: displaying scrollable lists of items
  • 48. Creating Custom UIs - Defining Layouts 48  Need to be designed with specific constraints  Wrong approach:  Best approach:  BoxInsetLayout: applies different window insets depending on the shape of the window screen without having views cropped near the edges of round screen  CurvedLayout: to visualize and manipulate vertical list of items optimized for round screens
  • 49. Creating Custom UIs - Lists 49  Select an item from a set of choices easily  Extend to the interested Activity the WearableRecyclerView class to create lists optimized for Wear 2.0  Recommended for a long list of simple items with a simple icon and a short string associated (i.e., application launcher, list of contacts...)
  • 50. Creating Custom UIs – Curved Layout 50  Use the WearableRecyclerView extended to the Activity  Set the setEdgeItemsCenteringEnabled(true) to align the first and the last elements of the list vertically centered on the screen  Use the WearableRecyclerView.setLayoutManager() method to set the elements  Enabling circular gesture scrolling calling setCircularScrollingGestureEnabled(true) method
  • 51. Creating Custom UIs – Showing confirmation Timers 51  Usually use the whole screen ensuring that the user can visualize the confirmation button larger enough to touch it to cancel an action  Automatic confirmation timers show users an animated timer that lets them cancel an action they just performed  The animations give users visual feedback when they complete an action
  • 52. Creating Custom UIs – Showing confirmation Timers 52  including the dipendencies in the build.gradle  Add a CircularProgressLayout element to layout
  • 53. Creating Custom UIs – Showing confirmation Timers 53  Implement the CircularProgressLayout.onTimerFinishedListener interface in the Activity
  • 54. Creating Custom UIs – Showing confirmation Timers 54  Set the duration of the timer and start it when the user completes an action  Show the confirmation animations creating an Intent that starts a new Activity including an EXTRA_ANIMATION_TYPE intent extra and an EXTRA_MESSAGE string:  SUCCESS_ANIMATION  FAILURE_ANIMATION  OPEN_ON_PHONE_ANIMATION
  • 55. Creating Custom UIs – Wear Navigation and Actions 55  Two tinteractive Drawers designed in Material Design  Navigation Drawer: switch between views in the app • Multi-page navigation drawer: present the contents of a navigation drawer in a single page or as multiple pages defining app:navigationStyle=‘’ multipage’’ in the XML layout  Action Drawer: easy access to common actions appearing at the bottom of the screen using context-specific user actions (similar to ActionBar to smartphone). It peeks when the user reaches the top or bottom of the scrolling content
  • 56. Create a WearableDrawerLayout 56  Example: declare an interface with a WearableDrawerLayout object as a root view of the layout supporting the nested scrolling. The main content  To add a multi-page navigation apply the attribute navigationStyle=‘’mult iPage’’ to the drawer
  • 57. Initialize the Drawer contents 57  Initialize the drawers’ lists of items exenting the WearableDrawerAdapter to populate the navigation drawer contents  Populate the action drawer contents in the layout XML file using app:actionMenu attribute  Initialize the contents of the drawer
  • 58. Ambient mode 58  Visualize the current Activity in a low-power mode saving battery on Wear device • Update dipendencies to build.gradle • Add wearable shared library • Add WAKE_LOCK permission
  • 59. Ambient mode - handle transitions 59  If the user covers the screen with their palm, the system switches the activity to Ambient mode  Note: by default when the app runs on a device, palming the screen does not switch an app into Ambient mode causing the Activity to exit and the home screen to appear
  • 60. Ambient mode - handle transitions 60  When the Activity switches to ambient mode, the system calls onEnterAmbient() method  When the user taps the screen or brings up the wrist, the Activity switches from Ambient mode to Interactive mode calling onExitAmbient() method  Update the information on the screen using onUpdateAmbient() method  Note: carefully balance display updates to not compromise the battery consumption. To realize battery savings, updates should be no more than once every 10 seconds. For apps that have to be updated frequently use an AlarmManager to wake the processor • Example: change the text color to white and set the antialias to false • Example: change the text color to green and set the antialias to true
  • 61. Multi-function Buttons 61  Android Wear supports extra physical buttons in addition to power button  onKeyDown() method  Note: find a method that searches the number of available buttons on wearable device Available set of possible keycodes that the app can receive and convert them to a specific in-app actions
  • 62. Using Wrist Gestures 62  Enable quick one-handed interactions with the app when the touch screen is inconvenient  Example of use:  scroll through notifications with one hand while holding a cup of coffe with the other  In app for jogging where the navigation through vertical screens shows the steps, time elapsed  ...  To activate them on the Wearable, confirm gestures to turn on by selecting Settings > Gestures > Wirst Gestures On
  • 63. Using Wrist Gestures 63  Curved layout with predefined gestures  The WaerableRecyclerView class automatically supports wirst gestures using predefined actions for occurrences when the view has focus previous item ReturnSelect an itemNext item
  • 64.  Using KeyEvents to customize functions defined by user action  Using KeyEvents The events are delivered to the top Activity that implements KeyEvent.CallBack that listens the key event related to the wrist gestures Using Wrist Gestures 64
  • 65.  Android Wear 2.0 allows to communicate with a network directly without access to an Android or iOS phone Sending and Sync Data 65  Wearable Data Layer API is used to manage data between Wear 1.0 and Phone  DataItem provides data storage with automatic syncing between the phone and wearable  Message good for remote procedure calls for one-way requests or request/response communication model (i.e., controlling the media player from wearable)  Asset for sending bolbs of data conserving Bluetooth bandwidth (i.e., images) froom phone to wearable  WearableListenerService when it needed to send data items (i.e., sensors states) or messages in backround  DataListener for important data layer events when the user is actively using the app in foreground  Channel to transfer large data items (i.e., movies or music) from phone to wearable  For more details: https://developer.android.com/training/wearables/data- layer/index.html
  • 66. Cloud Messaging  To send notifications, apps can directely use Firebase Cloud Messaging (FCM) which replcaes Google Cloud Messaging (GCM)  FCM is supported on Wear 2.0  For more details see: https://firebase.google.com/docs/cloud- messaging/concept-options  FMC sends messages to the device by collecting a registration token for it when the Wear app runs  By default notifications are shared form a phone app to watch. For standalone Wear apps FMC could be displayed independentlyThe FMC message is in JSON format including:  Notification payload: when a notifiation payload is received by a watch, the data is displayed to a user directely in the notification stream. When the user tap the notification, the app is launched  Data payload: set of custom key/value pairs. The payload is delivered as data to the Wear app
  • 67.  Android Wear Online Lessons: http://www.udacity.com  https://developer.android.com/training/building-wearables.html  https://developer.android.com/training/wearables/apps/creating. html  https://developer.android.com/training/wearables/notifications/no ti-styles.html  https://developer.android.com/training/wearables/notifications/co mpatibility.html  https://developer.android.com/training/wearables/apps/index.ht ml  https://developer.android.com/training/wearables/ui/index.html References 67