Merge "Start service intent when contact is being displayed"
diff --git a/samples/SampleSyncAdapter/AndroidManifest.xml b/samples/SampleSyncAdapter/AndroidManifest.xml
index ec8b779..25e9e99 100644
--- a/samples/SampleSyncAdapter/AndroidManifest.xml
+++ b/samples/SampleSyncAdapter/AndroidManifest.xml
@@ -77,6 +77,15 @@
                 android:name="android.provider.CONTACTS_STRUCTURE"
                 android:resource="@xml/contacts" />
         </service>
+        <!-- The view notification service -->
+        <service
+            android:name=".notifier.NotifierService"
+            android:exported="true">
+            <!--
+                No intent-filter here! This activity is only ever launched by
+                someone who explicitly knows the class name
+            -->
+        </service>
         <activity
             android:name=".authenticator.AuthenticatorActivity"
             android:label="@string/ui_activity_title"
diff --git a/samples/SampleSyncAdapter/res/xml-v14/contacts.xml b/samples/SampleSyncAdapter/res/xml-v14/contacts.xml
index 09b9e8f..5517729 100644
--- a/samples/SampleSyncAdapter/res/xml-v14/contacts.xml
+++ b/samples/SampleSyncAdapter/res/xml-v14/contacts.xml
@@ -23,6 +23,7 @@
     createContactActivity="com.example.android.samplesync.editor.ContactEditorActivity"
     inviteContactActivity="com.example.android.samplesync.editor.ContactEditorActivity"
     inviteContactActionLabel="@string/invite_action_label"
+    viewContactNotifyService="com.example.android.samplesync.notifier.NotifierService"
 >
 
     <ContactsDataKind
diff --git a/samples/SampleSyncAdapter/src/com/example/android/samplesync/notifier/NotifierService.java b/samples/SampleSyncAdapter/src/com/example/android/samplesync/notifier/NotifierService.java
new file mode 100644
index 0000000..f21207b
--- /dev/null
+++ b/samples/SampleSyncAdapter/src/com/example/android/samplesync/notifier/NotifierService.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed 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.
+ */
+package com.example.android.samplesync.notifier;
+
+import android.app.IntentService;
+import android.content.Intent;
+import android.util.Log;
+
+/**
+ * Service to handle view notifications. This allows the sample sync adapter to update the
+ * information when the contact is being looked at
+ */
+public class NotifierService extends IntentService {
+    private static final String TAG = "NotifierService";
+
+    public NotifierService() {
+        super(TAG);
+    }
+
+    @Override
+    protected void onHandleIntent(Intent intent) {
+        // In reality, we would write some data (e.g. a high-res picture) to the contact.
+        // for this demo, we just write a line to the log
+        Log.i(TAG, "Contact opened: " + intent.getData());
+    }
+}