From 33a1ea297d926ed58c79375dc9f1df782236aaa8 Mon Sep 17 00:00:00 2001 From: Bert McMeen Date: Fri, 10 Jun 2016 15:50:54 -0700 Subject: Docs: Fixed one of the addListener() links Bug: 28454953 Change-Id: I00002c8bba42e972331d5d80193094606243e252 --- docs/html/training/wearables/data-layer/events.jd | 61 ++++++++++++----------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/docs/html/training/wearables/data-layer/events.jd b/docs/html/training/wearables/data-layer/events.jd index 9bed9d548aad..20f219d69188 100644 --- a/docs/html/training/wearables/data-layer/events.jd +++ b/docs/html/training/wearables/data-layer/events.jd @@ -22,21 +22,21 @@ the call ends up making with listeners.

Wait for the Status of Data Layer Calls

You'll notice that calls to the Data Layer API sometimes return a -PendingResult, +PendingResult, such as -putDataItem(). -As soon as the PendingResult is created, +putDataItem(). +As soon as the PendingResult is created, the operation is queued in the background. If you do nothing else after this, the operation eventually completes silently. However, you'll usually want to do something with the result after the operation completes, so the -PendingResult +PendingResult lets you wait for the result status, either synchronously or asynchronously.

Asynchronous calls

If your code is running on the main UI thread, do not make blocking calls to the Data Layer API. You can run the calls asynchronously by adding a callback method -to the PendingResult object, +to the PendingResult object, which fires when the operation is completed:

 pendingResult.setResultCallback(new ResultCallback<DataItemResult>() {
@@ -51,12 +51,12 @@ pendingResult.setResultCallback(new ResultCallback<DataItemResult>() {
 
 

Synchronous calls

If your code is running on a separate handler thread in a background service (which is the case -in a WearableListenerService), +in a WearableListenerService), it's fine for the calls to block. In this case, you can call -await() -on the PendingResult +await() +on the PendingResult object, which blocks until the request completes and returns a -Result +Result object:

@@ -79,7 +79,7 @@ To listen for data layer events, you have two options: