This sample aims to be as close to a real world example of a mobile and Wear app combination as possible. It has a more refined design and also provides a practical example of how a mobile app would interact and communicate with its wear counterpart.
The app itself is modeled after a hypothetical tourist attractions app that notifies the user when they are in close proximity to notable points of interest.
The Wear component shows tourist attraction images and summary information, and provides quick actions for nearby tourist attractions in a GridViewPager UI component.
Steps for trying out this sample:
This sample aims to demonstrate a number of different Android APIs and concepts relating to Android Wear and location using Google Play Services:
The sample also focuses on providing a simple, yet clean design and UI for both mobile and wearable apps with an extra level of visual polish compared to a traditional code sample.
Some of the UI widgets and design patterns used in the mobile app include:
The wearable app uses a number of techniques and UI widgets as well:
This sample uses the Gradle build system. To build this project, use the "gradlew build" command or use "Import Project" in Android Studio.
If you've found an error in this sample, please file an issue: https://github.com/googlesamples/android-XYZTouristAttractions
Patches are encouraged, and may be submitted by forking this project and submitting a pull request through GitHub. Please see CONTRIBUTING.md for more details.
Copyright 2017 The Android Open Source Project, Inc.
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
compile 'com.google.android.gms:play-services-location:11.4.0'
compile 'com.google.maps.android:android-maps-utils:0.3.4'
compile 'com.github.bumptech.glide:glide:3.6.1'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.google.android.gms:play-services-wearable:11.4.0'
compile 'com.android.support:support-v13:26.1.0'
compile project(':Shared')
compileSdkVersion 26
minSdkVersion 18
targetSdkVersion 26
versionCode 1
versionName "1.0"
compile 'com.android.support:support-v13:25.3.1'
compile 'com.google.android.gms:play-services-wearable:11.4.0'
compile 'com.google.android.gms:play-services-maps:11.4.0'
compile 'com.google.maps.android:android-maps-utils:0.3.4'
compileSdkVersion 26
minSdkVersion 18
targetSdkVersion 26
compile 'com.google.android.gms:play-services-maps:11.4.0'
compile 'com.google.android.gms:play-services-wearable:11.4.0'
compile 'com.android.support:support-v13:26.1.0'
compile 'com.google.android.support:wearable:2.0.5'
compile project(':Shared')
compileSdkVersion 26
versionCode 1
versionName "1.0"
minSdkVersion 18
targetSdkVersion 25
package com.example.android.xyztouristattractions
uses-permission
package com.example.android.xyztouristattractions.common
package com.example.android.xyztouristattractions
uses-permission
The main Wear activity that displays nearby attractions in a {@link android.support.wearable.view.GridViewPager}. Each row shows one attraction and each column shows information or actions for that particular attraction.
A background task to load the attraction data via the Wear DataApi. This can take a second or two sometimes as several images need to be loaded.
A Wear listener service, used to receive inbound messages from the Wear device.
A utility IntentService, used for a variety of asynchronous background operations that do not necessarily need to be tied to a UI.
Add geofences using Play Services
Called when a geofence is triggered
Called when a location update is requested
Called when the location has been updated
Clears the local device notification
Clears remote device notifications using the Wearable message API
Show the notification. Either the regular notification with wearable features added to enhance, or trigger the full micro app on the wearable. * @param cityId The city to trigger the notification for @param microApp If the micro app should be triggered or just enhanced notifications
Transfer the required data over to the wearable @param attractions list of attraction data to transfer over
A Wear listener service, used to receive inbound messages from other devices.
A utility IntentService, used for a variety of asynchronous background operations that do not necessarily need to be tied to a UI.
Trigger a message that asks the master device to start an activity. * @param context the context @param path the path that will be sent via the wearable message API @param name the tourist attraction name @param city the tourist attraction city
Clear the local notifications
Trigger a message to ask other devices to clear their notifications
Sends the actual message to ask other devices that are capable of showing "details" to start the appropriate activity * @param path the path to pass to the wearable message API @param extraInfo extra info that varies based on the path being sent