diff options
Diffstat (limited to 'docs/html/training')
-rw-r--r-- | docs/html/training/auto/start/index.jd | 155 | ||||
-rw-r--r-- | docs/html/training/basics/firstapp/creating-project.jd | 5 | ||||
-rw-r--r-- | docs/html/training/basics/firstapp/index.jd | 15 | ||||
-rw-r--r-- | docs/html/training/basics/firstapp/running-app.jd | 20 | ||||
-rw-r--r-- | docs/html/training/building-userinfo.jd | 8 | ||||
-rw-r--r-- | docs/html/training/contacts-provider/retrieve-names.jd | 1 | ||||
-rw-r--r-- | docs/html/training/sign-in/index.jd | 50 | ||||
-rw-r--r-- | docs/html/training/training_toc.cs | 5 | ||||
-rw-r--r-- | docs/html/training/wearables/watch-faces/index.jd | 3 | ||||
-rw-r--r-- | docs/html/training/wearables/watch-faces/interacting.jd | 133 |
10 files changed, 283 insertions, 112 deletions
diff --git a/docs/html/training/auto/start/index.jd b/docs/html/training/auto/start/index.jd index 22e7521..6c6f188 100644 --- a/docs/html/training/auto/start/index.jd +++ b/docs/html/training/auto/start/index.jd @@ -16,7 +16,7 @@ page.image=auto/images/assets/icons/auto_app_in_simulator.png <ol> <li><a href="#dev-project">Set Up an Auto Project</a></li> <li><a href="#build-it">Build Auto Apps</a></li> - <li><a href="#test-it">Run and Test Auto Apps</a></li> + <li><a href="#test-it-dhu">Run and Test Auto Apps </a></li> </ol> <h2>You should also read</h2> @@ -149,57 +149,124 @@ requirements, you can reduce the effort for building and testing your app. For more information, see <a href="{@docRoot}distribute/essentials/quality/auto.html">Auto App Quality</a>.</p> -<h2 id="test-it">Run and Test Auto Apps</h2> -<p>As you prepare to publish your app, make sure that your app looks correct -when projected on the Auto user interface. Use the Android Media Browser -simulator and Android Messaging simulators to view and test your audio or -messaging apps in a screen that looks similar to what is projected on Auto.</p> -<p>To get the simulators, open the -<a href="{@docRoot}tools/help/sdk-manager.html">SDK Manager</a> and download -them from <strong>Extras > Android Auto API Simulators</strong>.</p> +<h2 id="test-it-dhu">Run and Test Auto Apps </h2> -<p>Before you begin testing, compile your app in your development environment. -Install your app and the Android simulator for the features you want to test -(that is, audio or messaging) on a physical or virtual device running Android -5.0 (API level 21) or higher. To check the version of Android on the device, go -to <strong>Settings > About > Android Version</strong>.</p> +<p> + As you develop, you can run and test your app on your development machine + using the <em>Desktop Head Unit</em> (DHU). The DHU replaces the existing + simulators and enables your development machine to simulate a vehicle + dashboard system running Android Auto. +</p> -<h3 id="testing-audio-apps">Testing audio apps</h3> -<p>To run and test audio apps:</p> +<h3 id="installing-dhu">Installing the DHU</h3> <ol> -<li>Install the Android Media Browser simulator -({@code <sdk>/extras/google/simulators/media-browser-simulator.apk}) on -the test device. You can do this using -the <a href="{@docRoot}tools/help/adb.html#move">adb</a> command line tool.</li> -<li>Enable <a href="{@docRoot}tools/device.html#device-developer-options"> -developer options</a> on the test device.</li> -<li>Install your app on the test device.</li> -<li>Launch the Android Media Browser simulator to see how your audio app -appears in Auto. If your app does not appear, stop the simulator from -<strong>Settings > Apps</strong> then restart it.</li> + <li>Enable developer mode on your mobile device, as described in + <a href="{@docRoot}tools/device.html#developer-device-options">Enabling On-device + Developer Options</a>. </li> + <li>Compile your app in your development environment and install your app on + a physical mobile device running Android 5.0 (API level 21) or higher. To check the + version of Android on a Nexus device, go to + <strong>Settings > About phone</strong> (or <strong>About tablet</strong>) <strong>> + Android version</strong>.</li> + + <li>Install the + <a class="external-link" + href="https://play.google.com/store/apps/details?id=com.google.android.projection.gearhead&hl=en" + >Android Auto app</a> on the mobile device.</li> + <li>Open the <a href="{@docRoot}tools/help/sdk-manager.html">SDK Manager</a> and + download the DHU package <strong>Android Auto Desktop Head Unit emulator</strong> from the + <em>SDK Tools</em> tab. The DHU installs in the <code><sdk>/extras/google/auto/</code> + directory.</li> + <li>If you are running the DHU on Linux, you must also install + the portaudio, libpng, sdl2, and sdl2_ttf libraries. + The procedure to do this varies depending on your Linux distribution. For example, on + Debian-derived Linux distributions, you can install the libraries with this command: + +<pre class="no-pretty-print"> +$ sudo apt-get install libsdl2-2.0-0 libsdl2-ttf-2.0-0 libportaudio2 libpng12-0 +</pre> + + </li> </ol> -<h3 id="testing-messaging-apps">Testing messaging apps</h3> -<p>To run and test messaging apps:</p> +<div class="figure" style="width:330px"> + <img src="{@docRoot}images/training/auto-desktop-head-unit-server-running.png" + alt="" > + <p class="img-caption"> + <strong>Figure 2.</strong> Notification that the head unit server is running. + </p> +</div> +<img src="{@docRoot}images/training/auto-desktop-head-unit-context-menu-enabled.png" + alt="" > +<p class="img-caption"> + <strong>Figure 1.</strong> Context menu with developer options. +</p> + +<h3 id="connecting-dhu">Connecting the DHU to your mobile device</h3> + +<p>Run the DHU by connecting your mobile device to a development machine and setting up a connection to + the head unit server over <a href="{@docRoot}tools/help/adb.html">Android Debug Bridge + (ADB)</a>. Follow these steps to set up tunneling and start the DHU:</p> <ol> -<li>Install the Android Messaging simulator - ({@code <sdk>/extras/google/simulators/messaging-simulator.apk}) -on the test device. You can do this using the -<a href="{@docRoot}tools/help/adb.html#move">adb</a> command line tool.</li> -<li>Enable the simulator to read notifications posted on the system: -<ol type="a"> - <li>Enable <a href="{@docRoot}tools/device.html#device-developer-options"> -developer options</a> on the test device.</li> - <li>Click <strong>Settings > Sounds & Notifications > Notification - Access</strong> and check the box labeled - <strong>Messaging Simulator</strong>.</li> -</ol> -<li>Install your app on the test device.</li> -<li>Launch the Android Messaging Simulator to see how your messaging app appears -in Auto. If your app does not appear, stop the simulator from -<strong>Settings > Apps</strong> then restart it.</li> + <li>On the mobile device, enable Android Auto developer mode by starting the Android Auto + companion app, and then tapping the header image 10 times. + This step is only required the first time you run the companion app. + </li> + <li>If the server is not already running, select <strong>Start head unit server</strong> + from the Android Auto menu. + <p>On the device, a foreground service appears in the notification area. </p> + </li> + + <li>Connect the mobile device to the development machine via USB. Your device must be unlocked to + launch the DHU. + </li> + <li>On the development machine, run the following {@code adb} command to + forward socket connections from the + development machine's port 5277 to the same port number on the Android device. + This configuration allows the DHU to connect to the head unit server running on your phone over + a TCP socket. + <pre class="no-pretty-print">$ adb forward tcp:5277 tcp:5277</pre> + </li> + + <li>Start the DHU by running the command <code>desktop-head-unit.exe</code> (on Windows) + or <code>./desktop-head-unit</code> (on Mac or Linux) from the + <code><sdk>/extras/google/auto/</code> directory. + +<pre class="no-pretty-print">$ cd <sdk>/extras/google/auto +$ ./desktop-head-unit</pre> + + <p> + By default, the head unit server connects over port 5277. To override the host or port + (for example, to forward over SSH), use the <code>--adb</code> flag. + </p> + + </li> </ol> + +<div class="figure" style="width:432px"> + + <img src="{@docRoot}images/training/auto-desktop-head-unit-wkst-launch.png" + alt="" > + <p class="img-caption"> + <strong>Figure 4.</strong> DHU launches on the development machine. + </p> +</div> + + <img src="{@docRoot}images/training/auto-desktop-head-unit-launch.png" + alt="" > + <p class="img-caption"> + <strong>Figure 3.</strong> Android Auto launches on the mobile device. + </p> + +<p> + After you set up and start the DHU, you can run DHU commands from the command line to run and + test your app from the terminal. You can also run these commands by using keyboard shortcuts. For + more information about DHU configuration and commands, see <a href= + "{@docRoot}tools/help/desktop-head-unit.html">Desktop Head Unit</a>. +</p> + + diff --git a/docs/html/training/basics/firstapp/creating-project.jd b/docs/html/training/basics/firstapp/creating-project.jd index 79268a0..4bd92ee 100644 --- a/docs/html/training/basics/firstapp/creating-project.jd +++ b/docs/html/training/basics/firstapp/creating-project.jd @@ -24,8 +24,6 @@ next.link=running-app.html <h2>You should also read</h2> <ul> - <li><a href="{@docRoot}sdk/installing/index.html">Installing the -SDK</a></li> <li><a href="{@docRoot}tools/projects/index.html">Managing Projects</a></li> </ul> @@ -34,8 +32,7 @@ SDK</a></li> </div> <p>An Android project contains all the files that comprise the source code for your Android -app. The Android SDK tools make it easy to start a new Android project with a set of -default project directories and files.</p> +app.</p> <p>This lesson shows how to create a new project either using Android Studio or using the diff --git a/docs/html/training/basics/firstapp/index.jd b/docs/html/training/basics/firstapp/index.jd index 1b6e00f..4e3689a 100644 --- a/docs/html/training/basics/firstapp/index.jd +++ b/docs/html/training/basics/firstapp/index.jd @@ -12,7 +12,7 @@ helpoutsWidget=true <div id="tb-wrapper"> <div id="tb"> -<h2>Dependencies and prerequisites</h2> +<h2>Dependencies</h2> <ul> <li><a href="{@docRoot}sdk/index.html">Android Studio</a></li> @@ -37,14 +37,11 @@ to:</p> <a href="{@docRoot}tools/help/sdk-manager.html">SDK Manager</a>.</li> </ol> -<p class="note"><strong>Note:</strong> Make sure you install the most recent versions of Android -Studio and the Android SDK before you start this class. The procedures described in this class may -not apply to earlier versions.</p> +<p class="note"><strong>Note:</strong> Although most of this training class +expects that you're using Android Studio, some procedures include alternative +instructions for using +the SDK tools from the command line instead.</p> -<p>If you haven't already done these tasks, start by downloading the - <a href="{@docRoot}sdk/index.html">Android SDK</a> and following the install steps. - Once you've finished the setup, you're ready to begin this class.</p> - -<p>This class uses a tutorial format that incrementally builds a small Android app that teaches +<p>This class uses a tutorial format to create a small Android app that teaches you some fundamental concepts about Android development, so it's important that you follow each step.</p> diff --git a/docs/html/training/basics/firstapp/running-app.jd b/docs/html/training/basics/firstapp/running-app.jd index fdf0d1f..6e4605f 100644 --- a/docs/html/training/basics/firstapp/running-app.jd +++ b/docs/html/training/basics/firstapp/running-app.jd @@ -25,7 +25,7 @@ helpoutsWidget=true <ul> <li><a href="{@docRoot}tools/device.html">Using Hardware Devices</a></li> - <li><a href="{@docRoot}tools/devices/index.html">Managing Virtual Devices</a></li> + <li><a href="{@docRoot}tools/devices/managing-avds.html">Managing AVDs with AVD Manager</a></li> <li><a href="{@docRoot}tools/projects/index.html">Managing Projects</a></li> </ul> @@ -128,10 +128,6 @@ to first create an <a href="{@docRoot}tools/devices/index.html">Android Virtual AVD is a device configuration for the Android emulator that allows you to model a specific device.</p> -<div class="figure" style="width:457px"> - <img src="{@docRoot}images/screens_support/as-mac-avds-config.png" /> - <p class="img-caption"><strong>Figure 1.</strong> The AVD Manager showing a virtual device.</p> -</div> <h3>Create an AVD</h3> <ol> @@ -161,19 +157,11 @@ device.</p> </li> <li>Verify the configuration settings, then click <strong>Finish</strong>. </li> - <li>In the <strong>Android Virtual Device Manager</strong> window, click <strong>Create</strong>.</li> - <li>Enter an <strong>AVD Name</strong>.</li> - <li>Select a <strong>Device</strong> type. - <p>When you select a device type, most of the fields auto-populate.</p> - <li>For <strong>Skin</strong> select <strong>HVGA</strong>.</li> - <li>For <strong>SD Card</strong>, enter something small, like 10 MiB. - <p>It really doesn't matter what you enter here since you're not using any storage. But if you - reuse this AVD, you might have to adjust this setting.</p></li> - <li>Ignore the <strong>Emulation Options</strong> and click <strong>OK</strong>.</li> - <li>In the <strong>Result</strong> screen, click <strong>OK</strong>.</li> - <li>Close the <strong>Android Virtual Device Manager</strong> window.</li> </ol> +<p>For more information about using AVDs, see +<a href="{@docRoot}tools/devices/managing-avds.html">Managing AVDs with AVD Manager</a>.</p> + <h3>Run the app from Android Studio</h3> <ol> <li>In <strong>Android Studio</strong>, select your project and click <strong>Run</strong> diff --git a/docs/html/training/building-userinfo.jd b/docs/html/training/building-userinfo.jd index f9d77f7..40e5b94 100644 --- a/docs/html/training/building-userinfo.jd +++ b/docs/html/training/building-userinfo.jd @@ -1,9 +1,9 @@ -page.title=Building Apps with User Info & Location +page.title=Building Apps with Contacts & Sign-In page.trainingcourse=true @jd:body -<p>These classes teach you how to add user personalization to your app. Some of the ways -you can do this is by identifying users, providing -information that's relevant to them, and providing information about the world around them.</p>
\ No newline at end of file +<p>These lessons teach you how to include contact information and authenticate users with the same +credentials they use for Google. These features allow your app to connect users with people they +care about and provide a personalized experience without creating new user accounts.</p> diff --git a/docs/html/training/contacts-provider/retrieve-names.jd b/docs/html/training/contacts-provider/retrieve-names.jd index 7106889..d97b81b 100644 --- a/docs/html/training/contacts-provider/retrieve-names.jd +++ b/docs/html/training/contacts-provider/retrieve-names.jd @@ -731,7 +731,6 @@ public class ContactsFragment extends Fragment implements Define ListView and item layouts. </li> <li> - <li> Define a Fragment that displays the list of contacts. </li> <li> diff --git a/docs/html/training/sign-in/index.jd b/docs/html/training/sign-in/index.jd index 9d49fd9..d7c8e1d 100644 --- a/docs/html/training/sign-in/index.jd +++ b/docs/html/training/sign-in/index.jd @@ -1,5 +1,5 @@ page.title=Adding Sign-In -page.tags=authentication,signin,social,google+ +page.tags=authentication,signin page.article=true page.trainingcourse=true @jd:body @@ -11,13 +11,13 @@ page.trainingcourse=true alt="Google maps sample image"> <p> - The Google+ platform for Android lets you authenticate a user with the same credentials they use - on Google every day. Once a user signs in with Google, you can create more engaging experiences - and drive usage of your app. + Google Sign-In for Android lets you authenticate a user with the same credentials they use on + Google. After a user signs in with Google, you can create more engaging experiences and drive + usage of your app. </p> <p> - The <a href="https://developers.google.com/+/mobile/android/">Google+ Android API</a> allows + The <a href="https://developers.google.com/identity/sign-in/android/">Google Android API</a> allows you to integrate sign-in and social features into your app. </p> @@ -26,43 +26,27 @@ page.trainingcourse=true <h4>Trusted authentication</h4> <p> - Google+ Sign-In is a simple, trusted, and secure way to let people sign in to your app with their - Google credentials and bring along their Google+ info.<br> - <a href="https://developers.google.com/+/mobile/android/sign-in" class="external-link">Add - sign-in</a>. + Google Sign-In is a simple, trusted, and secure way to let people sign in to your app with their + Google credentials.<br> + <a href="https://developers.google.com/identity/sign-in/android/sign-in" class="external-link">Add + Sign-in</a>. </p> <h4>Access the profile and social graph</h4> <p> - Once users have signed in with Google, your app can welcome them by name, display their picture, - connect them with friends, and lots more.<br> - <a href="https://developers.google.com/+/mobile/android/people" class="external-link">Access the - social graph</a>. -</p> - -<h4>Stand out in the stream</h4> -<p> - Interactive posts is a rich way of sharing to Google+. It lets users prompt friends to take - specific actions in your app from a Google+ post, like "listen," "RSVP," "check-in," and over 100 - more actions.<br> - <a class="external-link" href="https://developers.google.com/+/mobile/android/share">Post - interactive content</a>. -</p> - -<h4>Recommend content</h4> -<p> - Add a native +1 button so users can recommend content from your app. These endorsements can give - your app more credibility and help it grow faster.<br> - <a class="external-link" href="https://developers.google.com/+/mobile/android/recommend">Add the - +1 button</a>. + After users have signed in with Google, your app can welcome them by name and display their + picture. If your app requests social scopes, it can connect users with friends, and access + age range, language, and public profile information.<br> + <a href="https://developers.google.com/identity/sign-in/android/people" class="external-link"> + Getting Profile Information</a>. </p> <h2 id="start">Get Started</h2> <p> - The Google+ Android APIs are part of the Google Play services platform. To use Google+ features, + The Google Android APIs are part of the Google Play services platform. To use Google features, set up the Google Play services SDK in your app development project. For more information, see the <a class="external-link" href= - "https://developers.google.com/+/mobile/android/getting-started">Getting Started</a> guide for - the Google+ Platform for Android + "https://developers.google.com/identity/sign-in/android/start-integrating">Start Integrating</a> + guide for Google Sign-In. </p>
\ No newline at end of file diff --git a/docs/html/training/training_toc.cs b/docs/html/training/training_toc.cs index 5279969..2963345 100644 --- a/docs/html/training/training_toc.cs +++ b/docs/html/training/training_toc.cs @@ -811,7 +811,7 @@ include the action bar on devices running Android 2.1 or higher." <div class="nav-section-header"> <a href="<?cs var:toroot ?>training/building-userinfo.html"> <span class="small">Building Apps with</span><br/> - User Info & Sign-In + Contacts & Sign-In </a> </div> <ul> @@ -989,6 +989,9 @@ include the action bar on devices running Android 2.1 or higher." <a href="<?cs var:toroot ?>training/wearables/watch-faces/information.html">Showing Information in Watch Faces</a> </li> <li> + <a href="<?cs var:toroot ?>training/wearables/watch-faces/interacting.html">Creating Interactive Watch Faces</a> + </li> + <li> <a href="<?cs var:toroot ?>training/wearables/watch-faces/configuration.html">Providing Configuration Activities</a> </li> <li> diff --git a/docs/html/training/wearables/watch-faces/index.jd b/docs/html/training/wearables/watch-faces/index.jd index ec428c1..a329fda 100644 --- a/docs/html/training/wearables/watch-faces/index.jd +++ b/docs/html/training/wearables/watch-faces/index.jd @@ -65,6 +65,9 @@ Drawing Watch Faces</a></dt> <dt><a href="{@docRoot}training/wearables/watch-faces/information.html"> Showing Information in Watch Faces</a></dt> <dd>Learn how to incorporate contextual information into your watch face.</dd> +<dt><a href="{@docRoot}training/wearables/watch-faces/interacting.html"> +Creating Interactive Watch Faces</a></dt> +<dd>Learn how to enable the user to interact with your watch face.</dd> <dt><a href="{@docRoot}training/wearables/watch-faces/configuration.html"> Providing Configuration Activities</a></dt> <dd>Learn how to create watch faces with configurable parameters.</dd> diff --git a/docs/html/training/wearables/watch-faces/interacting.jd b/docs/html/training/wearables/watch-faces/interacting.jd new file mode 100644 index 0000000..5a44fde --- /dev/null +++ b/docs/html/training/wearables/watch-faces/interacting.jd @@ -0,0 +1,133 @@ +page.title=Creating Interactive Watch Faces + +@jd:body + +<div id="tb-wrapper"> +<div id="tb"> +<h2>This lesson teaches you to</h2> +<ol> + <li><a href="#Construct">Construct an Interactive Watch Face</a></li> + <li><a href="#Handle">Handle Gestures</a></li> +</ol> +<h2>You should also read</h2> +<ul> + <li><a href="{@docRoot}design/wear/watchfaces.html">Watch Faces for Android Wear</a></li> +</ul> +<h2>Related Samples</h2> + <ul> + <li><a href="{@docRoot}samples/WatchFace/index.html">WatchFace</a></li> + </ul> +</div> +</div> + +<p>Your watch's display is more than just a pretty face: Users can interact with it. +For example, a user might tap the watch face to learn what song is currently playing, or +to see the day's agenda. Android Wear allows Android Wear watch faces to accept +the single-tap gesture at a given location on the watch face, as long as there's not another +UI element that also responds to that gesture. + +<p>This lesson teaches you how to implement an interactive watch face by first constructing the +watch face style, and then implementing gesture handling.</p> + +<p class="note"><strong>Note:</strong> Before beginning development work on your interactive watch +face, you should be sure to read the <a href="{@docRoot}design/wear/watchfaces.html">Watch Faces for +Android Wear</a> design guide. + +<h2 id="Construct">Handling Tap Events</h2> + +<p>When constructing an interactive watch-face style, the first thing the app must do is tell the +system that the watch face receives <a href="{@docRoot}design/wear/watchfaces.html#ag">tap events</a>. +The following example shows how to do this: + +<pre> +setWatchFaceStyle(new WatchFaceStyle.Builder(mService) + .setAcceptsTapEvents(true) + // other style customizations + .build()); +</pre> + +<p>When the system detects a tap on the watch face, it triggers the +<a href="{@docRoot}reference/android/support/wearable/watchface/WatchFaceService.Engine.html#onTapCommand(int, int, int, long)"> +{@code WatchFaceService.Engine.onTapCommand()}</a> method. Override this method in your +implementation of +<a href="{@docRoot}reference/android/support/wearable/watchface/WatchFaceService.Engine.html"> +{@code WatchFaceService.Engine}</a>to initiate the action you wish to perform, such +as showing a detailed step count or changing the theme of the watch face. The code snippet +in <a href="#Handle">Handle Gestures</a> shows an example of such an +implementation.</p> + +<h2 id="Handle">Handle Gestures</h2> + +<p> To provide a consistent user experience, the system +reserves gestures such as drag and long-press for system UI elements. +Therefore, the system does not send raw touch events to the watch face. Instead, the system forwards specific commands to the +<a href="{@docRoot}reference/android/support/wearable/watchface/WatchFaceService.Engine.html#onTapCommand(int, int, int, long)"> +onTapCommand()</a> method. + +<p>The system sends the first command, +<a href="{@docRoot}reference/android/support/wearable/watchface/WatchFaceService.html#TAP_TYPE_TOUCH"> +{@code TAP_TYPE_TOUCH}</a>, when the user initially touches the +screen. This event lets you provide visual feedback to the user on touch. Your app should not +launch a UI when this event triggers. Launching a UI prevents drag events from opening the app +launcher, settings shade, and notifications stream.</p> + +<p>Before sending the next command, the system judges whether the contact is a single tap, which is +<a href="{@docRoot}design/wear/watchfaces.html#ag">the only gesture allowed</a>. If the user +immediately lifts their finger, the system determines that a single tap took place, and forwards +a +<a href="{@docRoot}reference/android/support/wearable/watchface/WatchFaceService.html#TAP_TYPE_TAP"</a> +{@code TAP_TYPE_TAP}</a> event. If the user does not immediately lift their finger, the system +forwards a +<a href="{@docRoot}reference/android/support/wearable/watchface/WatchFaceService.html#TAP_TYPE_TOUCH_CANCEL"</a> +{@code TAP_TYPE_TOUCH_CANCEL}</a> event. Once the user has triggered a +<a href="{@docRoot}reference/android/support/wearable/watchface/WatchFaceService.html#TAP_TYPE_TOUCH_CANCEL"</a> +{@code TAP_TYPE_TOUCH_CANCEL}</a> event, they cannot trigger a +<a href="{@docRoot}reference/android/support/wearable/watchface/WatchFaceService.html#TAP_TYPE_TAP"</a> +{@code TAP_TYPE_TAP}</a> event until they +make a new contact with the screen.</p> + +<p>The following example shows you how to implement tap events on a watch face:</p> + + +<pre> +@Override +public void onTapCommand( + @TapType int tapType, int x, int y, long eventTime) { + switch (tapType) { + case WatchFaceService.TAP_TYPE_TAP: + hideTapHighlight(); + if (withinTapRegion(x, y)) { + // Implement the tap action + // (e.g. show detailed step count) + onWatchFaceTap(); + } + break; + + case WatchFaceService.TAP_TYPE_TOUCH: + if (withinTapRegion(x, y)) { + // Provide visual feedback of touch event + startTapHighlight(x, y, eventTime); + } + break; + + case WatchFaceService.TAP_TYPE_TOUCH_CANCEL: + hideTapHighlight(); + break; + + default: + super.onTapCommand(tapType, x, y, eventTime); + break; + } +} +</pre> + +<p>In this example, the app determines what kind of event has taken place, +and responds accordingly. If the event is initial contact by the user's finger, +the app displays visual feedback. If the event is an immediate lifting +of the finger after contact, it performs the action on which the +user tapped. If the event is prolonged contact by the finger, the app +does nothing.</p> + + + + |