Home | History | Annotate | only in /developers/build/prebuilts/gradle/SynchronizedNotifications
Up to higher level directory
NameDateSize
.google/21-Aug-2018
Application/21-Aug-2018
build.gradle21-Aug-201814
CONTRIB.md21-Aug-20181.6K
CONTRIBUTING.md21-Aug-20181.5K
gradle/21-Aug-2018
gradlew21-Aug-20185K
gradlew.bat21-Aug-20182.3K
LICENSE21-Aug-201811.1K
README.md21-Aug-20184.4K
screenshots/21-Aug-2018
settings.gradle21-Aug-201848
Shared/21-Aug-2018
Wearable/21-Aug-2018

README.md

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