Home | History | Annotate | only in /developers/build/prebuilts/gradle/SynchronizedNotifications
Up to higher level directory
NameDateSize
.google/10-Mar-2015
Application/10-Mar-2015
build.gradle16-Dec-201414
CONTRIB.md16-Dec-20141.6K
CONTRIBUTING.md10-Mar-20151.5K
gradle/16-Dec-2014
gradlew16-Dec-20145K
gradlew.bat16-Dec-20142.3K
LICENSE16-Dec-201411.1K
NOTICE10-Mar-2015613
README.md10-Mar-20154.4K
screenshots/10-Mar-2015
settings.gradle16-Dec-201447
Shared/10-Mar-2015
Wearable/10-Mar-2015

README.md

      1 Android SynchronizedNotifications Sample
      2 ===================================
      3 
      4 A basic sample showing how to use simple or synchronized notifications.
      5 This allows users to dismiss events from either their phone or wearable device simultaneously.
      6 
      7 Introduction
      8 ------------
      9 
     10 The [DataAPI][1] exposes an API for components to read or write data items and assets between
     11 the handhelds and wearables. A [DataItem][2] is synchronized across all devices in an Android Wear network.
     12 It is possible to set data items while not connected to any nodes. Those data items will be synchronized
     13 when the nodes eventually come online.
     14 
     15 This example presents three buttons that would trigger three different combinations of
     16 notifications on the handset and the watch:
     17 
     18 1. The first button builds a simple local-only notification on the handset.
     19 2. The second one creates a wearable-only notification by putting a data item in the shared data
     20 store and having a [com.google.android.gms.wearable.WearableListenerService][3] listen for
     21 that on the wearable.
     22 3. The third one creates a local notification and a wearable notification by combining the above
     23 two. It, however, demonstrates how one can set things up so that the dismissal of one
     24 notification results in the dismissal of the other one.
     25 
     26 In the #2 and #3 items, the following code is used to synchronize the data between the handheld
     27 and the wearable devices using DataAPI.
     28 
     29 ```java
     30 PutDataMapRequest putDataMapRequest = PutDataMapRequest.create(path);
     31 putDataMapRequest.getDataMap().putString(Constants.KEY_CONTENT, content);
     32 putDataMapRequest.getDataMap().putString(Constants.KEY_TITLE, title);
     33 PutDataRequest request = putDataMapRequest.asPutDataRequest();
     34 Wearable.DataApi.putDataItem(mGoogleApiClient, request)
     35         .setResultCallback(new ResultCallback<DataApi.DataItemResult>() {
     36             @Override
     37             public void onResult(DataApi.DataItemResult dataItemResult) {
     38                 if (!dataItemResult.getStatus().isSuccess()) {
     39                     Log.e(TAG, "buildWatchOnlyNotification(): Failed to set the data, "
     40                             + "status: " + dataItemResult.getStatus().getStatusCode());
     41                 }
     42             }
     43         });
     44 ```
     45 
     46 [1]: http://developer.android.com/reference/com/google/android/gms/wearable/DataApi.html#putDataItem(com.google.android.gms.common.api.GoogleApiClient%2C%20com.google.android.gms.wearable.PutDataRequest)
     47 [2]: http://developer.android.com/reference/com/google/android/gms/wearable/DataItem.html
     48 [3]: https://developer.android.com/reference/com/google/android/gms/wearable/WearableListenerService.html
     49 
     50 Pre-requisites
     51 --------------
     52 
     53 - Android SDK v21
     54 - Android Build Tools v21.1.1
     55 - Android Support Repository
     56 
     57 Screenshots
     58 -------------
     59 
     60 <img src="screenshots/different_notifications_phone.png" height="400" alt="Screenshot"/> <img src="screenshots/different_notifications_wearable.png" height="400" alt="Screenshot"/> <img src="screenshots/notification_options.png" height="400" alt="Screenshot"/> <img src="screenshots/watch_only_notification.png" height="400" alt="Screenshot"/> 
     61 
     62 Getting Started
     63 ---------------
     64 
     65 This sample uses the Gradle build system. To build this project, use the
     66 "gradlew build" command or use "Import Project" in Android Studio.
     67 
     68 Support
     69 -------
     70 
     71 - Google+ Community: https://plus.google.com/communities/105153134372062985968
     72 - Stack Overflow: http://stackoverflow.com/questions/tagged/android
     73 
     74 If you've found an error in this sample, please file an issue:
     75 https://github.com/googlesamples/android-SynchronizedNotifications
     76 
     77 Patches are encouraged, and may be submitted by forking this project and
     78 submitting a pull request through GitHub. Please see CONTRIBUTING.md for more details.
     79 
     80 License
     81 -------
     82 
     83 Copyright 2014 The Android Open Source Project, Inc.
     84 
     85 Licensed to the Apache Software Foundation (ASF) under one or more contributor
     86 license agreements.  See the NOTICE file distributed with this work for
     87 additional information regarding copyright ownership.  The ASF licenses this
     88 file to you under the Apache License, Version 2.0 (the "License"); you may not
     89 use this file except in compliance with the License.  You may obtain a copy of
     90 the License at
     91 
     92 http://www.apache.org/licenses/LICENSE-2.0
     93 
     94 Unless required by applicable law or agreed to in writing, software
     95 distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
     96 WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
     97 License for the specific language governing permissions and limitations under
     98 the License.
     99