merge in mnc-release history after reset to mnc-dev
diff --git a/samples/browseable/ActionBarCompat-Basic/res/values-v11/template-styles.xml b/samples/browseable/ActionBarCompat-Basic/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/ActionBarCompat-Basic/res/values-v11/template-styles.xml
+++ b/samples/browseable/ActionBarCompat-Basic/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/ActionBarCompat-Basic/res/values-v21/base-template-styles.xml b/samples/browseable/ActionBarCompat-Basic/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/ActionBarCompat-Basic/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/ActionBarCompat-Basic/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/ActionBarCompat-Basic/res/values/template-styles.xml b/samples/browseable/ActionBarCompat-Basic/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/ActionBarCompat-Basic/res/values/template-styles.xml
+++ b/samples/browseable/ActionBarCompat-Basic/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/ActionBarCompat-ListPopupMenu/res/values-v11/template-styles.xml b/samples/browseable/ActionBarCompat-ListPopupMenu/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/ActionBarCompat-ListPopupMenu/res/values-v11/template-styles.xml
+++ b/samples/browseable/ActionBarCompat-ListPopupMenu/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/ActionBarCompat-ListPopupMenu/res/values-v21/base-template-styles.xml b/samples/browseable/ActionBarCompat-ListPopupMenu/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/ActionBarCompat-ListPopupMenu/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/ActionBarCompat-ListPopupMenu/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/ActionBarCompat-ListPopupMenu/res/values/template-styles.xml b/samples/browseable/ActionBarCompat-ListPopupMenu/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/ActionBarCompat-ListPopupMenu/res/values/template-styles.xml
+++ b/samples/browseable/ActionBarCompat-ListPopupMenu/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/ActionBarCompat-ShareActionProvider/res/values-v11/template-styles.xml b/samples/browseable/ActionBarCompat-ShareActionProvider/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/ActionBarCompat-ShareActionProvider/res/values-v11/template-styles.xml
+++ b/samples/browseable/ActionBarCompat-ShareActionProvider/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/ActionBarCompat-ShareActionProvider/res/values-v21/base-template-styles.xml b/samples/browseable/ActionBarCompat-ShareActionProvider/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/ActionBarCompat-ShareActionProvider/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/ActionBarCompat-ShareActionProvider/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/ActionBarCompat-ShareActionProvider/res/values/template-styles.xml b/samples/browseable/ActionBarCompat-ShareActionProvider/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/ActionBarCompat-ShareActionProvider/res/values/template-styles.xml
+++ b/samples/browseable/ActionBarCompat-ShareActionProvider/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/ActionBarCompat-Styled/res/values-v11/template-styles.xml b/samples/browseable/ActionBarCompat-Styled/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/ActionBarCompat-Styled/res/values-v11/template-styles.xml
+++ b/samples/browseable/ActionBarCompat-Styled/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/ActionBarCompat-Styled/res/values-v21/base-template-styles.xml b/samples/browseable/ActionBarCompat-Styled/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/ActionBarCompat-Styled/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/ActionBarCompat-Styled/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/ActionBarCompat-Styled/res/values/template-styles.xml b/samples/browseable/ActionBarCompat-Styled/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/ActionBarCompat-Styled/res/values/template-styles.xml
+++ b/samples/browseable/ActionBarCompat-Styled/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/ActiveNotifications/res/values-v11/template-styles.xml b/samples/browseable/ActiveNotifications/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/ActiveNotifications/res/values-v11/template-styles.xml
+++ b/samples/browseable/ActiveNotifications/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/ActiveNotifications/res/values-v21/base-template-styles.xml b/samples/browseable/ActiveNotifications/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/ActiveNotifications/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/ActiveNotifications/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/ActiveNotifications/res/values/template-styles.xml b/samples/browseable/ActiveNotifications/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/ActiveNotifications/res/values/template-styles.xml
+++ b/samples/browseable/ActiveNotifications/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/ActivityInstrumentation/res/values-v11/template-styles.xml b/samples/browseable/ActivityInstrumentation/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/ActivityInstrumentation/res/values-v11/template-styles.xml
+++ b/samples/browseable/ActivityInstrumentation/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/ActivityInstrumentation/res/values-v21/base-template-styles.xml b/samples/browseable/ActivityInstrumentation/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/ActivityInstrumentation/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/ActivityInstrumentation/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/ActivityInstrumentation/res/values/template-styles.xml b/samples/browseable/ActivityInstrumentation/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/ActivityInstrumentation/res/values/template-styles.xml
+++ b/samples/browseable/ActivityInstrumentation/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/ActivitySceneTransitionBasic/res/values-v11/template-styles.xml b/samples/browseable/ActivitySceneTransitionBasic/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/ActivitySceneTransitionBasic/res/values-v11/template-styles.xml
+++ b/samples/browseable/ActivitySceneTransitionBasic/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/ActivitySceneTransitionBasic/res/values-v21/base-template-styles.xml b/samples/browseable/ActivitySceneTransitionBasic/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/ActivitySceneTransitionBasic/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/ActivitySceneTransitionBasic/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/ActivitySceneTransitionBasic/res/values/template-styles.xml b/samples/browseable/ActivitySceneTransitionBasic/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/ActivitySceneTransitionBasic/res/values/template-styles.xml
+++ b/samples/browseable/ActivitySceneTransitionBasic/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/AdvancedImmersiveMode/res/values-v11/template-styles.xml b/samples/browseable/AdvancedImmersiveMode/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/AdvancedImmersiveMode/res/values-v11/template-styles.xml
+++ b/samples/browseable/AdvancedImmersiveMode/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/AdvancedImmersiveMode/res/values-v21/base-template-styles.xml b/samples/browseable/AdvancedImmersiveMode/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/AdvancedImmersiveMode/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/AdvancedImmersiveMode/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/AdvancedImmersiveMode/res/values/template-styles.xml b/samples/browseable/AdvancedImmersiveMode/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/AdvancedImmersiveMode/res/values/template-styles.xml
+++ b/samples/browseable/AdvancedImmersiveMode/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/AgendaData/Application/res/values-v11/template-styles.xml b/samples/browseable/AgendaData/Application/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/AgendaData/Application/res/values-v11/template-styles.xml
+++ b/samples/browseable/AgendaData/Application/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/AgendaData/Application/res/values-v21/base-template-styles.xml b/samples/browseable/AgendaData/Application/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/AgendaData/Application/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/AgendaData/Application/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/AgendaData/Application/res/values/template-styles.xml b/samples/browseable/AgendaData/Application/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/AgendaData/Application/res/values/template-styles.xml
+++ b/samples/browseable/AgendaData/Application/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/AgendaData/Application/src/com.example.android.wearable.agendadata/MainActivity.java b/samples/browseable/AgendaData/Application/src/com.example.android.wearable.agendadata/MainActivity.java
index 8e4063d..34e327b 100644
--- a/samples/browseable/AgendaData/Application/src/com.example.android.wearable.agendadata/MainActivity.java
+++ b/samples/browseable/AgendaData/Application/src/com.example.android.wearable.agendadata/MainActivity.java
@@ -33,7 +33,6 @@
 import com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks;
 import com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener;
 import com.google.android.gms.common.api.ResultCallback;
-import com.google.android.gms.common.data.FreezableUtils;
 import com.google.android.gms.wearable.DataApi;
 import com.google.android.gms.wearable.DataItem;
 import com.google.android.gms.wearable.DataItemBuffer;
@@ -96,28 +95,29 @@
                     .setResultCallback(new ResultCallback<DataItemBuffer>() {
                         @Override
                         public void onResult(DataItemBuffer result) {
-                            if (result.getStatus().isSuccess()) {
-                                deleteDataItems(result);
-                            } else {
-                                if (Log.isLoggable(TAG, Log.DEBUG)) {
-                                    Log.d(TAG, "onDeleteEventsClicked(): failed to get Data Items");
+                            try {
+                                if (result.getStatus().isSuccess()) {
+                                    deleteDataItems(result);
+                                } else {
+                                    if (Log.isLoggable(TAG, Log.DEBUG)) {
+                                        Log.d(TAG,"onDeleteEventsClicked(): failed to get Data "
+                                                + "Items");
+
+                                    }
                                 }
+                            } finally {
+                                result.release();
                             }
-                            result.close();
                         }
                     });
         } else {
             Log.e(TAG, "Failed to delete data items"
-                     + " - Client disconnected from Google Play Services");
+                    + " - Client disconnected from Google Play Services");
         }
     }
 
-    private void deleteDataItems(DataItemBuffer dataItems) {
+    private void deleteDataItems(final DataItemBuffer dataItemList) {
         if (mGoogleApiClient.isConnected()) {
-            // Store the DataItem URIs in a List and close the buffer. Then use these URIs
-            // to delete the DataItems.
-            final List<DataItem> dataItemList = FreezableUtils.freezeIterable(dataItems);
-            dataItems.close();
             for (final DataItem dataItem : dataItemList) {
                 final Uri dataItemUri = dataItem.getUri();
                 // In a real calendar application, this might delete the corresponding calendar
diff --git a/samples/browseable/AgendaData/Wearable/src/com.example.android.wearable.agendadata/HomeListenerService.java b/samples/browseable/AgendaData/Wearable/src/com.example.android.wearable.agendadata/HomeListenerService.java
index ef47977..0cbda71 100644
--- a/samples/browseable/AgendaData/Wearable/src/com.example.android.wearable.agendadata/HomeListenerService.java
+++ b/samples/browseable/AgendaData/Wearable/src/com.example.android.wearable.agendadata/HomeListenerService.java
@@ -75,7 +75,6 @@
                 UpdateNotificationForDataItem(event.getDataItem());
             }
         }
-        dataEvents.close();
     }
 
     @Override
diff --git a/samples/browseable/AppRestrictionEnforcer/res/values-v11/template-styles.xml b/samples/browseable/AppRestrictionEnforcer/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/AppRestrictionEnforcer/res/values-v11/template-styles.xml
+++ b/samples/browseable/AppRestrictionEnforcer/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/AppRestrictionEnforcer/res/values-v21/base-template-styles.xml b/samples/browseable/AppRestrictionEnforcer/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/AppRestrictionEnforcer/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/AppRestrictionEnforcer/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/AppRestrictionEnforcer/res/values/template-styles.xml b/samples/browseable/AppRestrictionEnforcer/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/AppRestrictionEnforcer/res/values/template-styles.xml
+++ b/samples/browseable/AppRestrictionEnforcer/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/AppRestrictionSchema/res/values-v11/template-styles.xml b/samples/browseable/AppRestrictionSchema/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/AppRestrictionSchema/res/values-v11/template-styles.xml
+++ b/samples/browseable/AppRestrictionSchema/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/AppRestrictionSchema/res/values-v21/base-template-styles.xml b/samples/browseable/AppRestrictionSchema/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/AppRestrictionSchema/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/AppRestrictionSchema/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/AppRestrictionSchema/res/values/template-styles.xml b/samples/browseable/AppRestrictionSchema/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/AppRestrictionSchema/res/values/template-styles.xml
+++ b/samples/browseable/AppRestrictionSchema/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/AppRestrictions/res/values-v11/template-styles.xml b/samples/browseable/AppRestrictions/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/AppRestrictions/res/values-v11/template-styles.xml
+++ b/samples/browseable/AppRestrictions/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/AppRestrictions/res/values-v21/base-template-styles.xml b/samples/browseable/AppRestrictions/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/AppRestrictions/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/AppRestrictions/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/AppRestrictions/res/values/template-styles.xml b/samples/browseable/AppRestrictions/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/AppRestrictions/res/values/template-styles.xml
+++ b/samples/browseable/AppRestrictions/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/AppUsageStatistics/res/values-v11/template-styles.xml b/samples/browseable/AppUsageStatistics/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/AppUsageStatistics/res/values-v11/template-styles.xml
+++ b/samples/browseable/AppUsageStatistics/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/AppUsageStatistics/res/values-v21/base-template-styles.xml b/samples/browseable/AppUsageStatistics/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/AppUsageStatistics/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/AppUsageStatistics/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/AppUsageStatistics/res/values/template-styles.xml b/samples/browseable/AppUsageStatistics/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/AppUsageStatistics/res/values/template-styles.xml
+++ b/samples/browseable/AppUsageStatistics/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/AutoBackupForApps/res/values-v11/template-styles.xml b/samples/browseable/AutoBackupForApps/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/AutoBackupForApps/res/values-v11/template-styles.xml
+++ b/samples/browseable/AutoBackupForApps/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/AutoBackupForApps/res/values-v21/base-template-styles.xml b/samples/browseable/AutoBackupForApps/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/AutoBackupForApps/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/AutoBackupForApps/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/AutoBackupForApps/res/values/template-styles.xml b/samples/browseable/AutoBackupForApps/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/AutoBackupForApps/res/values/template-styles.xml
+++ b/samples/browseable/AutoBackupForApps/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/BasicAccessibility/res/values-v11/template-styles.xml b/samples/browseable/BasicAccessibility/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/BasicAccessibility/res/values-v11/template-styles.xml
+++ b/samples/browseable/BasicAccessibility/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/BasicAccessibility/res/values-v21/base-template-styles.xml b/samples/browseable/BasicAccessibility/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/BasicAccessibility/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/BasicAccessibility/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/BasicAccessibility/res/values/template-styles.xml b/samples/browseable/BasicAccessibility/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/BasicAccessibility/res/values/template-styles.xml
+++ b/samples/browseable/BasicAccessibility/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/BasicAndroidKeyStore/res/values-v11/template-styles.xml b/samples/browseable/BasicAndroidKeyStore/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/BasicAndroidKeyStore/res/values-v11/template-styles.xml
+++ b/samples/browseable/BasicAndroidKeyStore/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/BasicAndroidKeyStore/res/values-v21/base-template-styles.xml b/samples/browseable/BasicAndroidKeyStore/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/BasicAndroidKeyStore/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/BasicAndroidKeyStore/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/BasicContactables/res/values-v11/template-styles.xml b/samples/browseable/BasicContactables/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/BasicContactables/res/values-v11/template-styles.xml
+++ b/samples/browseable/BasicContactables/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/BasicContactables/res/values-v21/base-template-styles.xml b/samples/browseable/BasicContactables/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/BasicContactables/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/BasicContactables/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/BasicContactables/res/values/template-styles.xml b/samples/browseable/BasicContactables/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/BasicContactables/res/values/template-styles.xml
+++ b/samples/browseable/BasicContactables/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/BasicGestureDetect/res/drawable-hdpi/ic_launcher.png b/samples/browseable/BasicGestureDetect/res/drawable-hdpi/ic_launcher.png
index b1efaf4..4252db1 100644
--- a/samples/browseable/BasicGestureDetect/res/drawable-hdpi/ic_launcher.png
+++ b/samples/browseable/BasicGestureDetect/res/drawable-hdpi/ic_launcher.png
Binary files differ
diff --git a/samples/browseable/BasicGestureDetect/res/drawable-mdpi/ic_launcher.png b/samples/browseable/BasicGestureDetect/res/drawable-mdpi/ic_launcher.png
index f5f9244..969456e 100644
--- a/samples/browseable/BasicGestureDetect/res/drawable-mdpi/ic_launcher.png
+++ b/samples/browseable/BasicGestureDetect/res/drawable-mdpi/ic_launcher.png
Binary files differ
diff --git a/samples/browseable/BasicGestureDetect/res/drawable-xhdpi/ic_launcher.png b/samples/browseable/BasicGestureDetect/res/drawable-xhdpi/ic_launcher.png
index 5d07b3f..608151a 100644
--- a/samples/browseable/BasicGestureDetect/res/drawable-xhdpi/ic_launcher.png
+++ b/samples/browseable/BasicGestureDetect/res/drawable-xhdpi/ic_launcher.png
Binary files differ
diff --git a/samples/browseable/BasicGestureDetect/res/drawable-xxhdpi/ic_launcher.png b/samples/browseable/BasicGestureDetect/res/drawable-xxhdpi/ic_launcher.png
index 6ef21e1..23ffa9a 100644
--- a/samples/browseable/BasicGestureDetect/res/drawable-xxhdpi/ic_launcher.png
+++ b/samples/browseable/BasicGestureDetect/res/drawable-xxhdpi/ic_launcher.png
Binary files differ
diff --git a/samples/browseable/BasicGestureDetect/res/values-v11/template-styles.xml b/samples/browseable/BasicGestureDetect/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/BasicGestureDetect/res/values-v11/template-styles.xml
+++ b/samples/browseable/BasicGestureDetect/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/BasicGestureDetect/res/values-v21/base-template-styles.xml b/samples/browseable/BasicGestureDetect/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/BasicGestureDetect/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/BasicGestureDetect/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/BasicGestureDetect/src/com.example.android.basicgesturedetect/GestureListener.java b/samples/browseable/BasicGestureDetect/src/com.example.android.basicgesturedetect/GestureListener.java
index 2e2921d..19b588a 100644
--- a/samples/browseable/BasicGestureDetect/src/com.example.android.basicgesturedetect/GestureListener.java
+++ b/samples/browseable/BasicGestureDetect/src/com.example.android.basicgesturedetect/GestureListener.java
@@ -16,6 +16,8 @@
 
 package com.example.android.basicgesturedetect;
 
+import android.annotation.TargetApi;
+import android.os.Build;
 import android.view.GestureDetector;
 import android.view.MotionEvent;
 
@@ -29,7 +31,7 @@
     @Override
     public boolean onSingleTapUp(MotionEvent e) {
         // Up motion completing a single tap occurred.
-        Log.i(TAG, "Single Tap Up");
+        Log.i(TAG, "Single Tap Up" + getTouchType(e));
         return false;
     }
 
@@ -37,14 +39,14 @@
     public void onLongPress(MotionEvent e) {
         // Touch has been long enough to indicate a long press.
         // Does not indicate motion is complete yet (no up event necessarily)
-        Log.i(TAG, "Long Press");
+        Log.i(TAG, "Long Press" + getTouchType(e));
     }
 
     @Override
     public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX,
     float distanceY) {
         // User attempted to scroll
-        Log.i(TAG, "Scroll");
+        Log.i(TAG, "Scroll" + getTouchType(e1));
         return false;
     }
 
@@ -52,27 +54,27 @@
     public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
     float velocityY) {
         // Fling event occurred.  Notification of this one happens after an "up" event.
-        Log.i(TAG, "Fling");
+        Log.i(TAG, "Fling" + getTouchType(e1));
         return false;
     }
 
     @Override
     public void onShowPress(MotionEvent e) {
         // User performed a down event, and hasn't moved yet.
-        Log.i(TAG, "Show Press");
+        Log.i(TAG, "Show Press" + getTouchType(e));
     }
 
     @Override
     public boolean onDown(MotionEvent e) {
         // "Down" event - User touched the screen.
-        Log.i(TAG, "Down");
+        Log.i(TAG, "Down" + getTouchType(e));
         return false;
     }
 
     @Override
     public boolean onDoubleTap(MotionEvent e) {
         // User tapped the screen twice.
-        Log.i(TAG, "Double tap");
+        Log.i(TAG, "Double tap" + getTouchType(e));
         return false;
     }
 
@@ -81,7 +83,7 @@
         // Since double-tap is actually several events which are considered one aggregate
         // gesture, there's a separate callback for an individual event within the doubletap
         // occurring.  This occurs for down, up, and move.
-        Log.i(TAG, "Event within double tap");
+        Log.i(TAG, "Event within double tap" + getTouchType(e));
         return false;
     }
 
@@ -89,8 +91,84 @@
     public boolean onSingleTapConfirmed(MotionEvent e) {
         // A confirmed single-tap event has occurred.  Only called when the detector has
         // determined that the first tap stands alone, and is not part of a double tap.
-        Log.i(TAG, "Single tap confirmed");
+        Log.i(TAG, "Single tap confirmed" + getTouchType(e));
         return false;
     }
     // END_INCLUDE(init_gestureListener)
+
+
+    /**
+     * Returns a human-readable string describing the type of touch that triggered a MotionEvent.
+     */
+
+    private static String getTouchType(MotionEvent e){
+
+        String touchTypeDescription = " ";
+        int touchType = e.getToolType(0);
+
+        switch (touchType) {
+            case MotionEvent.TOOL_TYPE_FINGER:
+                touchTypeDescription += "(finger)";
+                break;
+            case MotionEvent.TOOL_TYPE_STYLUS:
+                touchTypeDescription += "(stylus, ";
+                //Get some additional information about the stylus touch
+                float stylusPressure = e.getPressure();
+                touchTypeDescription += "pressure: " + stylusPressure;
+
+                if(Build.VERSION.SDK_INT >= 21) {
+                    touchTypeDescription += ", buttons pressed: " + getButtonsPressed(e);
+                }
+
+                touchTypeDescription += ")";
+                break;
+            case MotionEvent.TOOL_TYPE_ERASER:
+                touchTypeDescription += "(eraser)";
+                break;
+            case MotionEvent.TOOL_TYPE_MOUSE:
+                touchTypeDescription += "(mouse)";
+                break;
+            default:
+                touchTypeDescription += "(unknown tool)";
+                break;
+        }
+
+        return touchTypeDescription;
+    }
+
+    /**
+     * Returns a human-readable string listing all the stylus buttons that were pressed when the
+     * input MotionEvent occurred.
+     */
+    @TargetApi(21)
+    private static String getButtonsPressed(MotionEvent e){
+        String buttons = "";
+
+        if(e.isButtonPressed(MotionEvent.BUTTON_PRIMARY)){
+            buttons += " primary";
+        }
+
+        if(e.isButtonPressed(MotionEvent.BUTTON_SECONDARY)){
+            buttons += " secondary";
+        }
+
+        if(e.isButtonPressed(MotionEvent.BUTTON_TERTIARY)){
+            buttons += " tertiary";
+        }
+
+        if(e.isButtonPressed(MotionEvent.BUTTON_BACK)){
+            buttons += " back";
+        }
+
+        if(e.isButtonPressed(MotionEvent.BUTTON_FORWARD)){
+            buttons += " forward";
+        }
+
+        if (buttons.equals("")){
+            buttons = "none";
+        }
+
+        return buttons;
+    }
+
 }
diff --git a/samples/browseable/BasicImmersiveMode/res/values-v11/template-styles.xml b/samples/browseable/BasicImmersiveMode/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/BasicImmersiveMode/res/values-v11/template-styles.xml
+++ b/samples/browseable/BasicImmersiveMode/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/BasicImmersiveMode/res/values-v21/base-template-styles.xml b/samples/browseable/BasicImmersiveMode/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/BasicImmersiveMode/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/BasicImmersiveMode/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/BasicManagedProfile/res/values-v11/template-styles.xml b/samples/browseable/BasicManagedProfile/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/BasicManagedProfile/res/values-v11/template-styles.xml
+++ b/samples/browseable/BasicManagedProfile/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/BasicManagedProfile/res/values-v21/base-template-styles.xml b/samples/browseable/BasicManagedProfile/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/BasicManagedProfile/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/BasicManagedProfile/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/BasicManagedProfile/res/values/template-styles.xml b/samples/browseable/BasicManagedProfile/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/BasicManagedProfile/res/values/template-styles.xml
+++ b/samples/browseable/BasicManagedProfile/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/BasicMediaDecoder/res/values-v11/template-styles.xml b/samples/browseable/BasicMediaDecoder/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/BasicMediaDecoder/res/values-v11/template-styles.xml
+++ b/samples/browseable/BasicMediaDecoder/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/BasicMediaDecoder/res/values-v21/base-template-styles.xml b/samples/browseable/BasicMediaDecoder/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/BasicMediaDecoder/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/BasicMediaDecoder/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/BasicMediaDecoder/res/values/template-styles.xml b/samples/browseable/BasicMediaDecoder/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/BasicMediaDecoder/res/values/template-styles.xml
+++ b/samples/browseable/BasicMediaDecoder/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/BasicMediaRouter/res/values-v11/template-styles.xml b/samples/browseable/BasicMediaRouter/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/BasicMediaRouter/res/values-v11/template-styles.xml
+++ b/samples/browseable/BasicMediaRouter/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/BasicMediaRouter/res/values-v21/base-template-styles.xml b/samples/browseable/BasicMediaRouter/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/BasicMediaRouter/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/BasicMediaRouter/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/BasicMediaRouter/res/values/template-styles.xml b/samples/browseable/BasicMediaRouter/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/BasicMediaRouter/res/values/template-styles.xml
+++ b/samples/browseable/BasicMediaRouter/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/BasicMultitouch/res/values-v11/template-styles.xml b/samples/browseable/BasicMultitouch/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/BasicMultitouch/res/values-v11/template-styles.xml
+++ b/samples/browseable/BasicMultitouch/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/BasicMultitouch/res/values-v21/base-template-styles.xml b/samples/browseable/BasicMultitouch/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/BasicMultitouch/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/BasicMultitouch/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/BasicMultitouch/res/values/template-styles.xml b/samples/browseable/BasicMultitouch/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/BasicMultitouch/res/values/template-styles.xml
+++ b/samples/browseable/BasicMultitouch/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/BasicNetworking/res/values-v11/template-styles.xml b/samples/browseable/BasicNetworking/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/BasicNetworking/res/values-v11/template-styles.xml
+++ b/samples/browseable/BasicNetworking/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/BasicNetworking/res/values-v21/base-template-styles.xml b/samples/browseable/BasicNetworking/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/BasicNetworking/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/BasicNetworking/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/BasicNetworking/res/values/template-styles.xml b/samples/browseable/BasicNetworking/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/BasicNetworking/res/values/template-styles.xml
+++ b/samples/browseable/BasicNetworking/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/BasicNotifications/res/values-v11/template-styles.xml b/samples/browseable/BasicNotifications/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/BasicNotifications/res/values-v11/template-styles.xml
+++ b/samples/browseable/BasicNotifications/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/BasicNotifications/res/values-v21/base-template-styles.xml b/samples/browseable/BasicNotifications/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/BasicNotifications/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/BasicNotifications/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/BasicNotifications/res/values/template-styles.xml b/samples/browseable/BasicNotifications/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/BasicNotifications/res/values/template-styles.xml
+++ b/samples/browseable/BasicNotifications/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/BasicRenderScript/res/values-v11/template-styles.xml b/samples/browseable/BasicRenderScript/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/BasicRenderScript/res/values-v11/template-styles.xml
+++ b/samples/browseable/BasicRenderScript/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/BasicRenderScript/res/values-v21/base-template-styles.xml b/samples/browseable/BasicRenderScript/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/BasicRenderScript/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/BasicRenderScript/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/BasicRenderScript/res/values/template-styles.xml b/samples/browseable/BasicRenderScript/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/BasicRenderScript/res/values/template-styles.xml
+++ b/samples/browseable/BasicRenderScript/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/BasicSyncAdapter/res/values-v11/template-styles.xml b/samples/browseable/BasicSyncAdapter/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/BasicSyncAdapter/res/values-v11/template-styles.xml
+++ b/samples/browseable/BasicSyncAdapter/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/BasicSyncAdapter/res/values-v21/base-template-styles.xml b/samples/browseable/BasicSyncAdapter/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/BasicSyncAdapter/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/BasicSyncAdapter/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/BasicSyncAdapter/res/values/template-styles.xml b/samples/browseable/BasicSyncAdapter/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/BasicSyncAdapter/res/values/template-styles.xml
+++ b/samples/browseable/BasicSyncAdapter/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/BasicTransition/res/values-v11/template-styles.xml b/samples/browseable/BasicTransition/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/BasicTransition/res/values-v11/template-styles.xml
+++ b/samples/browseable/BasicTransition/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/BasicTransition/res/values-v21/base-template-styles.xml b/samples/browseable/BasicTransition/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/BasicTransition/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/BasicTransition/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/BasicTransition/res/values/template-styles.xml b/samples/browseable/BasicTransition/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/BasicTransition/res/values/template-styles.xml
+++ b/samples/browseable/BasicTransition/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/BatchStepSensor/res/values-v11/template-styles.xml b/samples/browseable/BatchStepSensor/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/BatchStepSensor/res/values-v11/template-styles.xml
+++ b/samples/browseable/BatchStepSensor/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/BatchStepSensor/res/values-v21/base-template-styles.xml b/samples/browseable/BatchStepSensor/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/BatchStepSensor/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/BatchStepSensor/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/BatchStepSensor/res/values/template-styles.xml b/samples/browseable/BatchStepSensor/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/BatchStepSensor/res/values/template-styles.xml
+++ b/samples/browseable/BatchStepSensor/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/BeamLargeFiles/res/values-v11/template-styles.xml b/samples/browseable/BeamLargeFiles/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/BeamLargeFiles/res/values-v11/template-styles.xml
+++ b/samples/browseable/BeamLargeFiles/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/BeamLargeFiles/res/values-v21/base-template-styles.xml b/samples/browseable/BeamLargeFiles/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/BeamLargeFiles/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/BeamLargeFiles/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/BluetoothAdvertisements/AndroidManifest.xml b/samples/browseable/BluetoothAdvertisements/AndroidManifest.xml
index 48084fc..cd2a65e 100644
--- a/samples/browseable/BluetoothAdvertisements/AndroidManifest.xml
+++ b/samples/browseable/BluetoothAdvertisements/AndroidManifest.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?xml version="1.0" encoding="utf-8"?>
 <!--
  Copyright 2013 The Android Open Source Project
 
@@ -17,23 +17,32 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="com.example.android.bluetoothadvertisements"
     android:versionCode="1"
-    android:versionName="1.0">
+    android:versionName="1.0" >
 
-    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
-    <uses-permission android:name="android.permission.BLUETOOTH"/>
+    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
+    <uses-permission android:name="android.permission.BLUETOOTH" />
 
-    <application android:allowBackup="true"
-        android:label="@string/app_name"
+    <application
+        android:allowBackup="true"
         android:icon="@drawable/ic_launcher"
-        android:theme="@style/AppTheme">
-
-        <activity android:name=".MainActivity"
-                  android:label="@string/app_name">
+        android:label="@string/app_name"
+        android:theme="@style/AppTheme" >
+        <activity
+            android:name=".MainActivity"
+            android:label="@string/app_name" >
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.LAUNCHER" />
             </intent-filter>
         </activity>
+
+        <!-- Service to handle BLE Advertising - Using a service allows advertising to continue
+             when the app is no longer on screen in a reliable manner.  -->
+        <service
+            android:name=".AdvertiserService"
+            android:enabled="true"
+            android:exported="false" >
+        </service>
     </application>
 
 </manifest>
diff --git a/samples/browseable/BluetoothAdvertisements/res/drawable-hdpi/ic_launcher.png b/samples/browseable/BluetoothAdvertisements/res/drawable-hdpi/ic_launcher.png
index b1efaf4..48d6465 100644
--- a/samples/browseable/BluetoothAdvertisements/res/drawable-hdpi/ic_launcher.png
+++ b/samples/browseable/BluetoothAdvertisements/res/drawable-hdpi/ic_launcher.png
Binary files differ
diff --git a/samples/browseable/BluetoothAdvertisements/res/drawable-mdpi/ic_launcher.png b/samples/browseable/BluetoothAdvertisements/res/drawable-mdpi/ic_launcher.png
index f5f9244..42b3b1e 100644
--- a/samples/browseable/BluetoothAdvertisements/res/drawable-mdpi/ic_launcher.png
+++ b/samples/browseable/BluetoothAdvertisements/res/drawable-mdpi/ic_launcher.png
Binary files differ
diff --git a/samples/browseable/BluetoothAdvertisements/res/drawable-xhdpi/ic_launcher.png b/samples/browseable/BluetoothAdvertisements/res/drawable-xhdpi/ic_launcher.png
index 5d07b3f..13663e8 100644
--- a/samples/browseable/BluetoothAdvertisements/res/drawable-xhdpi/ic_launcher.png
+++ b/samples/browseable/BluetoothAdvertisements/res/drawable-xhdpi/ic_launcher.png
Binary files differ
diff --git a/samples/browseable/BluetoothAdvertisements/res/drawable-xxhdpi/ic_launcher.png b/samples/browseable/BluetoothAdvertisements/res/drawable-xxhdpi/ic_launcher.png
index 6ef21e1..5e84f3a 100644
--- a/samples/browseable/BluetoothAdvertisements/res/drawable-xxhdpi/ic_launcher.png
+++ b/samples/browseable/BluetoothAdvertisements/res/drawable-xxhdpi/ic_launcher.png
Binary files differ
diff --git a/samples/browseable/BluetoothAdvertisements/res/values-v11/template-styles.xml b/samples/browseable/BluetoothAdvertisements/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/BluetoothAdvertisements/res/values-v11/template-styles.xml
+++ b/samples/browseable/BluetoothAdvertisements/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/BluetoothAdvertisements/res/values-v21/base-template-styles.xml b/samples/browseable/BluetoothAdvertisements/res/values-v21/base-template-styles.xml
index 0bb9fbf..a0d1bf1 100644
--- a/samples/browseable/BluetoothAdvertisements/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/BluetoothAdvertisements/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
             <item name="android:colorPrimary">@color/colorPrimary</item>
             <item name="android:colorPrimaryDark">@color/colorPrimaryDark</item>
             <item name="android:textColorPrimary">@color/textColorPrimary</item>
diff --git a/samples/browseable/BluetoothAdvertisements/res/values/strings.xml b/samples/browseable/BluetoothAdvertisements/res/values/strings.xml
index 197178d..927f3b6 100644
--- a/samples/browseable/BluetoothAdvertisements/res/values/strings.xml
+++ b/samples/browseable/BluetoothAdvertisements/res/values/strings.xml
@@ -26,5 +26,8 @@
     <string name="seconds">seconds.</string>
     <string name="scan_start_toast">Scanning for</string>
     <string name="already_scanning">Scanning already started.</string>
+    <string name="no_name">(no name)</string>
+    <string name="start_error_unknown">unknown error</string>
+    <string name="advertising_timedout">Advertising stopped due to timeout.</string>
 
 </resources>
\ No newline at end of file
diff --git a/samples/browseable/BluetoothAdvertisements/res/values/template-styles.xml b/samples/browseable/BluetoothAdvertisements/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/BluetoothAdvertisements/res/values/template-styles.xml
+++ b/samples/browseable/BluetoothAdvertisements/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/BluetoothAdvertisements/src/com.example.android.bluetoothadvertisements/AdvertiserFragment.java b/samples/browseable/BluetoothAdvertisements/src/com.example.android.bluetoothadvertisements/AdvertiserFragment.java
index f8daefb..c97b904 100644
--- a/samples/browseable/BluetoothAdvertisements/src/com.example.android.bluetoothadvertisements/AdvertiserFragment.java
+++ b/samples/browseable/BluetoothAdvertisements/src/com.example.android.bluetoothadvertisements/AdvertiserFragment.java
@@ -1,10 +1,26 @@
+/*
+ * Copyright (C) 2015 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.bluetoothadvertisements;
 
-import android.bluetooth.BluetoothAdapter;
 import android.bluetooth.le.AdvertiseCallback;
-import android.bluetooth.le.AdvertiseData;
-import android.bluetooth.le.AdvertiseSettings;
-import android.bluetooth.le.BluetoothLeAdvertiser;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
 import android.os.Bundle;
 import android.support.v4.app.Fragment;
 import android.view.LayoutInflater;
@@ -16,67 +32,121 @@
 /**
  * Allows user to start & stop Bluetooth LE Advertising of their device.
  */
-public class AdvertiserFragment extends Fragment {
+public class AdvertiserFragment extends Fragment implements View.OnClickListener {
 
-    private BluetoothAdapter mBluetoothAdapter;
-
-    private BluetoothLeAdvertiser mBluetoothLeAdvertiser;
-
-    private AdvertiseCallback mAdvertiseCallback;
-
+    /**
+     * Lets user toggle BLE Advertising.
+     */
     private Switch mSwitch;
 
     /**
-     * Must be called after object creation by MainActivity.
-     *
-     * @param btAdapter the local BluetoothAdapter
+     * Listens for notifications that the {@code AdvertiserService} has failed to start advertising.
+     * This Receiver deals with Fragment UI elements and only needs to be active when the Fragment
+     * is on-screen, so it's defined and registered in code instead of the Manifest.
      */
-    public void setBluetoothAdapter(BluetoothAdapter btAdapter) {
-        this.mBluetoothAdapter = btAdapter;
-        mBluetoothLeAdvertiser = mBluetoothAdapter.getBluetoothLeAdvertiser();
-    }
+    private BroadcastReceiver advertisingFailureReceiver;
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
-        setRetainInstance(true);
+
+        advertisingFailureReceiver = new BroadcastReceiver() {
+
+            /**
+             * Receives Advertising error codes from {@code AdvertiserService} and displays error messages
+             * to the user. Sets the advertising toggle to 'false.'
+             */
+            @Override
+            public void onReceive(Context context, Intent intent) {
+
+                int errorCode = intent.getIntExtra(AdvertiserService.ADVERTISING_FAILED_EXTRA_CODE, -1);
+
+                mSwitch.setChecked(false);
+
+                String errorMessage = getString(R.string.start_error_prefix);
+                switch (errorCode) {
+                    case AdvertiseCallback.ADVERTISE_FAILED_ALREADY_STARTED:
+                        errorMessage += " " + getString(R.string.start_error_already_started);
+                        break;
+                    case AdvertiseCallback.ADVERTISE_FAILED_DATA_TOO_LARGE:
+                        errorMessage += " " + getString(R.string.start_error_too_large);
+                        break;
+                    case AdvertiseCallback.ADVERTISE_FAILED_FEATURE_UNSUPPORTED:
+                        errorMessage += " " + getString(R.string.start_error_unsupported);
+                        break;
+                    case AdvertiseCallback.ADVERTISE_FAILED_INTERNAL_ERROR:
+                        errorMessage += " " + getString(R.string.start_error_internal);
+                        break;
+                    case AdvertiseCallback.ADVERTISE_FAILED_TOO_MANY_ADVERTISERS:
+                        errorMessage += " " + getString(R.string.start_error_too_many);
+                        break;
+                    case AdvertiserService.ADVERTISING_TIMED_OUT:
+                        errorMessage = " " + getString(R.string.advertising_timedout);
+                        break;
+                    default:
+                        errorMessage += " " + getString(R.string.start_error_unknown);
+                }
+
+                Toast.makeText(getActivity(), errorMessage, Toast.LENGTH_LONG).show();
+            }
+        };
     }
 
     @Override
     public View onCreateView(LayoutInflater inflater, ViewGroup container,
-            Bundle savedInstanceState) {
+                             Bundle savedInstanceState) {
 
         View view = inflater.inflate(R.layout.fragment_advertiser, container, false);
 
         mSwitch = (Switch) view.findViewById(R.id.advertise_switch);
-        mSwitch.setOnClickListener(new View.OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                onSwitchClicked(v);
-            }
-        });
+        mSwitch.setOnClickListener(this);
 
         return view;
     }
 
+    /**
+     * When app comes on screen, check if BLE Advertisements are running, set switch accordingly,
+     * and register the Receiver to be notified if Advertising fails.
+     */
     @Override
-    public void onStop() {
-        super.onStop();
+    public void onResume() {
+        super.onResume();
 
-        if(mAdvertiseCallback != null){
-            stopAdvertising();
+        if (AdvertiserService.running) {
+            mSwitch.setChecked(true);
+        } else {
+            mSwitch.setChecked(false);
         }
+
+        IntentFilter failureFilter = new IntentFilter(AdvertiserService.ADVERTISING_FAILED);
+        getActivity().registerReceiver(advertisingFailureReceiver, failureFilter);
+
+    }
+
+    /**
+     * When app goes off screen, unregister the Advertising failure Receiver to stop memory leaks.
+     * (and because the app doesn't care if Advertising fails while the UI isn't active)
+     */
+    @Override
+    public void onPause() {
+        super.onPause();
+        getActivity().unregisterReceiver(advertisingFailureReceiver);
+    }
+
+    /**
+     * Returns Intent addressed to the {@code AdvertiserService} class.
+     */
+    private static Intent getServiceIntent(Context c) {
+        return new Intent(c, AdvertiserService.class);
     }
 
     /**
      * Called when switch is toggled - starts or stops advertising.
-     *
-     * @param view is the Switch View object
      */
-    public void onSwitchClicked(View view) {
-
+    @Override
+    public void onClick(View v) {
         // Is the toggle on?
-        boolean on = ((Switch) view).isChecked();
+        boolean on = ((Switch) v).isChecked();
 
         if (on) {
             startAdvertising();
@@ -86,105 +156,20 @@
     }
 
     /**
-     * Starts BLE Advertising.
+     * Starts BLE Advertising by starting {@code AdvertiserService}.
      */
     private void startAdvertising() {
-
-        mAdvertiseCallback = new SampleAdvertiseCallback();
-
-        if (mBluetoothLeAdvertiser != null) {
-            mBluetoothLeAdvertiser.startAdvertising(buildAdvertiseSettings(), buildAdvertiseData(),
-                    mAdvertiseCallback);
-        } else {
-            mSwitch.setChecked(false);
-            Toast.makeText(getActivity(), getString(R.string.bt_null), Toast.LENGTH_LONG).show();
-        }
+        Context c = getActivity();
+        c.startService(getServiceIntent(c));
     }
 
     /**
-     * Stops BLE Advertising.
+     * Stops BLE Advertising by stopping {@code AdvertiserService}.
      */
     private void stopAdvertising() {
-
-        if (mBluetoothLeAdvertiser != null) {
-
-            mBluetoothLeAdvertiser.stopAdvertising(mAdvertiseCallback);
-            mAdvertiseCallback = null;
-
-        } else {
-            mSwitch.setChecked(false);
-            Toast.makeText(getActivity(), getString(R.string.bt_null), Toast.LENGTH_LONG).show();
-        }
+        Context c = getActivity();
+        c.stopService(getServiceIntent(c));
+        mSwitch.setChecked(false);
     }
 
-    /**
-     * Returns an AdvertiseData object which includes the Service UUID and Device Name.
-     */
-    private AdvertiseData buildAdvertiseData() {
-
-        // Note: There is a strict limit of 31 Bytes on packets sent over BLE Advertisements.
-        // This includes everything put into AdvertiseData including UUIDs, device info, &
-        // arbitrary service or manufacturer data.
-        // Attempting to send packets over this limit will result in a failure with error code
-        // AdvertiseCallback.ADVERTISE_FAILED_DATA_TOO_LARGE. Catch this error in the
-        // onStartFailure() method of an AdvertiseCallback implementation.
-
-        AdvertiseData.Builder dataBuilder = new AdvertiseData.Builder();
-        dataBuilder.addServiceUuid(Constants.Service_UUID);
-        dataBuilder.setIncludeDeviceName(true);
-
-        return dataBuilder.build();
-    }
-
-    /**
-     * Returns an AdvertiseSettings object set to use low power (to help preserve battery life).
-     */
-    private AdvertiseSettings buildAdvertiseSettings() {
-        AdvertiseSettings.Builder settingsBuilder = new AdvertiseSettings.Builder();
-        settingsBuilder.setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_LOW_POWER);
-
-        return settingsBuilder.build();
-    }
-
-    /**
-     * Custom callback after Advertising succeeds or fails to start.
-     */
-    private class SampleAdvertiseCallback extends AdvertiseCallback {
-
-        @Override
-        public void onStartFailure(int errorCode) {
-            super.onStartFailure(errorCode);
-
-            mSwitch.setChecked(false);
-
-            String errorMessage = getString(R.string.start_error_prefix);
-            switch (errorCode) {
-                case AdvertiseCallback.ADVERTISE_FAILED_ALREADY_STARTED:
-                    errorMessage += " " + getString(R.string.start_error_already_started);
-                    break;
-                case AdvertiseCallback.ADVERTISE_FAILED_DATA_TOO_LARGE:
-                    errorMessage += " " + getString(R.string.start_error_too_large);
-                    break;
-                case AdvertiseCallback.ADVERTISE_FAILED_FEATURE_UNSUPPORTED:
-                    errorMessage += " " + getString(R.string.start_error_unsupported);
-                    break;
-                case AdvertiseCallback.ADVERTISE_FAILED_INTERNAL_ERROR:
-                    errorMessage += " " + getString(R.string.start_error_internal);
-                    break;
-                case AdvertiseCallback.ADVERTISE_FAILED_TOO_MANY_ADVERTISERS:
-                    errorMessage += " " + getString(R.string.start_error_too_many);
-                    break;
-            }
-
-            Toast.makeText(getActivity(), errorMessage, Toast.LENGTH_LONG).show();
-
-        }
-
-        @Override
-        public void onStartSuccess(AdvertiseSettings settingsInEffect) {
-            super.onStartSuccess(settingsInEffect);
-            // Don't need to do anything here, advertising successfully started.
-        }
-    }
-
-}
+}
\ No newline at end of file
diff --git a/samples/browseable/BluetoothAdvertisements/src/com.example.android.bluetoothadvertisements/AdvertiserService.java b/samples/browseable/BluetoothAdvertisements/src/com.example.android.bluetoothadvertisements/AdvertiserService.java
new file mode 100644
index 0000000..0cc3ff0
--- /dev/null
+++ b/samples/browseable/BluetoothAdvertisements/src/com.example.android.bluetoothadvertisements/AdvertiserService.java
@@ -0,0 +1,223 @@
+package com.example.android.bluetoothadvertisements;
+
+import android.app.Service;
+import android.bluetooth.BluetoothAdapter;
+import android.bluetooth.BluetoothManager;
+import android.bluetooth.le.AdvertiseCallback;
+import android.bluetooth.le.AdvertiseData;
+import android.bluetooth.le.AdvertiseSettings;
+import android.bluetooth.le.BluetoothLeAdvertiser;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Handler;
+import android.os.IBinder;
+import android.util.Log;
+import android.widget.Toast;
+
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Manages BLE Advertising independent of the main app.
+ * If the app goes off screen (or gets killed completely) advertising can continue because this
+ * Service is maintaining the necessary Callback in memory.
+ */
+public class AdvertiserService extends Service {
+
+    private static final String TAG = AdvertiserService.class.getSimpleName();
+
+    /**
+     * A global variable to let AdvertiserFragment check if the Service is running without needing
+     * to start or bind to it.
+     * This is the best practice method as defined here:
+     * https://groups.google.com/forum/#!topic/android-developers/jEvXMWgbgzE
+     */
+    public static boolean running = false;
+
+    public static final String ADVERTISING_FAILED =
+            "com.example.android.bluetoothadvertisements.advertising_failed";
+
+    public static final String ADVERTISING_FAILED_EXTRA_CODE = "failureCode";
+
+    public static final int ADVERTISING_TIMED_OUT = 6;
+
+    private BluetoothLeAdvertiser mBluetoothLeAdvertiser;
+
+    private AdvertiseCallback mAdvertiseCallback;
+
+    private Handler mHandler;
+
+    private Runnable timeoutRunnable;
+
+    /**
+     * Length of time to allow advertising before automatically shutting off. (10 minutes)
+     */
+    private long TIMEOUT = TimeUnit.MILLISECONDS.convert(10, TimeUnit.MINUTES);
+
+    @Override
+    public void onCreate() {
+        running = true;
+        initialize();
+        startAdvertising();
+        setTimeout();
+        super.onCreate();
+    }
+
+    @Override
+    public void onDestroy() {
+        /**
+         * Note that onDestroy is not guaranteed to be called quickly or at all. Services exist at
+         * the whim of the system, and onDestroy can be delayed or skipped entirely if memory need
+         * is critical.
+         */
+        running = false;
+        stopAdvertising();
+        mHandler.removeCallbacks(timeoutRunnable);
+        super.onDestroy();
+    }
+
+    /**
+     * Required for extending service, but this will be a Started Service only, so no need for
+     * binding.
+     */
+    @Override
+    public IBinder onBind(Intent intent) {
+        return null;
+    }
+
+    /**
+     * Get references to system Bluetooth objects if we don't have them already.
+     */
+    private void initialize() {
+        if (mBluetoothLeAdvertiser == null) {
+            BluetoothManager mBluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
+            if (mBluetoothManager != null) {
+                BluetoothAdapter mBluetoothAdapter = mBluetoothManager.getAdapter();
+                if (mBluetoothAdapter != null) {
+                    mBluetoothLeAdvertiser = mBluetoothAdapter.getBluetoothLeAdvertiser();
+                } else {
+                    Toast.makeText(this, getString(R.string.bt_null), Toast.LENGTH_LONG).show();
+                }
+            } else {
+                Toast.makeText(this, getString(R.string.bt_null), Toast.LENGTH_LONG).show();
+            }
+        }
+
+    }
+
+    /**
+     * Starts a delayed Runnable that will cause the BLE Advertising to timeout and stop after a
+     * set amount of time.
+     */
+    private void setTimeout(){
+        mHandler = new Handler();
+        timeoutRunnable = new Runnable() {
+            @Override
+            public void run() {
+                Log.d(TAG, "AdvertiserService has reached timeout of "+TIMEOUT+" milliseconds, stopping advertising.");
+                sendFailureIntent(ADVERTISING_TIMED_OUT);
+                stopSelf();
+            }
+        };
+        mHandler.postDelayed(timeoutRunnable, TIMEOUT);
+    }
+
+    /**
+     * Starts BLE Advertising.
+     */
+    private void startAdvertising() {
+        Log.d(TAG, "Service: Starting Advertising");
+
+        if (mAdvertiseCallback == null) {
+            AdvertiseSettings settings = buildAdvertiseSettings();
+            AdvertiseData data = buildAdvertiseData();
+            mAdvertiseCallback = new SampleAdvertiseCallback();
+
+            if (mBluetoothLeAdvertiser != null) {
+                mBluetoothLeAdvertiser.startAdvertising(settings, data,
+                        mAdvertiseCallback);
+            }
+        }
+    }
+
+    /**
+     * Stops BLE Advertising.
+     */
+    private void stopAdvertising() {
+        Log.d(TAG, "Service: Stopping Advertising");
+        if (mBluetoothLeAdvertiser != null) {
+            mBluetoothLeAdvertiser.stopAdvertising(mAdvertiseCallback);
+            mAdvertiseCallback = null;
+        }
+    }
+
+    /**
+     * Returns an AdvertiseData object which includes the Service UUID and Device Name.
+     */
+    private AdvertiseData buildAdvertiseData() {
+
+        /**
+         * Note: There is a strict limit of 31 Bytes on packets sent over BLE Advertisements.
+         *  This includes everything put into AdvertiseData including UUIDs, device info, &
+         *  arbitrary service or manufacturer data.
+         *  Attempting to send packets over this limit will result in a failure with error code
+         *  AdvertiseCallback.ADVERTISE_FAILED_DATA_TOO_LARGE. Catch this error in the
+         *  onStartFailure() method of an AdvertiseCallback implementation.
+         */
+
+        AdvertiseData.Builder dataBuilder = new AdvertiseData.Builder();
+        dataBuilder.addServiceUuid(Constants.Service_UUID);
+        dataBuilder.setIncludeDeviceName(true);
+
+        /* For example - this will cause advertising to fail (exceeds size limit) */
+        //String failureData = "asdghkajsghalkxcjhfa;sghtalksjcfhalskfjhasldkjfhdskf";
+        //dataBuilder.addServiceData(Constants.Service_UUID, failureData.getBytes());
+
+        return dataBuilder.build();
+    }
+
+    /**
+     * Returns an AdvertiseSettings object set to use low power (to help preserve battery life)
+     * and disable the built-in timeout since this code uses its own timeout runnable.
+     */
+    private AdvertiseSettings buildAdvertiseSettings() {
+        AdvertiseSettings.Builder settingsBuilder = new AdvertiseSettings.Builder();
+        settingsBuilder.setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_LOW_POWER);
+        settingsBuilder.setTimeout(0);
+        return settingsBuilder.build();
+    }
+
+    /**
+     * Custom callback after Advertising succeeds or fails to start. Broadcasts the error code
+     * in an Intent to be picked up by AdvertiserFragment and stops this Service.
+     */
+    private class SampleAdvertiseCallback extends AdvertiseCallback {
+
+        @Override
+        public void onStartFailure(int errorCode) {
+            super.onStartFailure(errorCode);
+
+            Log.d(TAG, "Advertising failed");
+            sendFailureIntent(errorCode);
+            stopSelf();
+
+        }
+
+        @Override
+        public void onStartSuccess(AdvertiseSettings settingsInEffect) {
+            super.onStartSuccess(settingsInEffect);
+            Log.d(TAG, "Advertising successfully started");
+        }
+    }
+
+    /**
+     * Builds and sends a broadcast intent indicating Advertising has failed. Includes the error
+     * code as an extra. This is intended to be picked up by the {@code AdvertiserFragment}.
+     */
+    private void sendFailureIntent(int errorCode){
+        Intent failureIntent = new Intent();
+        failureIntent.setAction(ADVERTISING_FAILED);
+        failureIntent.putExtra(ADVERTISING_FAILED_EXTRA_CODE, errorCode);
+        sendBroadcast(failureIntent);
+    }
+
+}
\ No newline at end of file
diff --git a/samples/browseable/BluetoothAdvertisements/src/com.example.android.bluetoothadvertisements/Constants.java b/samples/browseable/BluetoothAdvertisements/src/com.example.android.bluetoothadvertisements/Constants.java
index d3941e2..793ac92 100644
--- a/samples/browseable/BluetoothAdvertisements/src/com.example.android.bluetoothadvertisements/Constants.java
+++ b/samples/browseable/BluetoothAdvertisements/src/com.example.android.bluetoothadvertisements/Constants.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2015 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.bluetoothadvertisements;
 
 import android.os.ParcelUuid;
diff --git a/samples/browseable/BluetoothAdvertisements/src/com.example.android.bluetoothadvertisements/MainActivity.java b/samples/browseable/BluetoothAdvertisements/src/com.example.android.bluetoothadvertisements/MainActivity.java
index f0044a3..7ea3891 100644
--- a/samples/browseable/BluetoothAdvertisements/src/com.example.android.bluetoothadvertisements/MainActivity.java
+++ b/samples/browseable/BluetoothAdvertisements/src/com.example.android.bluetoothadvertisements/MainActivity.java
@@ -1,18 +1,18 @@
 /*
-* Copyright 2013 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.
-*/
+ * Copyright (C) 2015 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.bluetoothadvertisements;
 
@@ -39,7 +39,7 @@
         setContentView(R.layout.activity_main);
         setTitle(R.string.activity_main_title);
 
-        if (savedInstanceState == null ) {
+        if (savedInstanceState == null) {
 
             mBluetoothAdapter = ((BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE))
                     .getAdapter();
@@ -112,11 +112,11 @@
         FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
 
         ScannerFragment scannerFragment = new ScannerFragment();
+        // Fragments can't access system services directly, so pass it the BluetoothAdapter
         scannerFragment.setBluetoothAdapter(mBluetoothAdapter);
         transaction.replace(R.id.scanner_fragment_container, scannerFragment);
 
         AdvertiserFragment advertiserFragment = new AdvertiserFragment();
-        advertiserFragment.setBluetoothAdapter(mBluetoothAdapter);
         transaction.replace(R.id.advertiser_fragment_container, advertiserFragment);
 
         transaction.commit();
diff --git a/samples/browseable/BluetoothAdvertisements/src/com.example.android.bluetoothadvertisements/ScanResultAdapter.java b/samples/browseable/BluetoothAdvertisements/src/com.example.android.bluetoothadvertisements/ScanResultAdapter.java
index 0f905ea..5a9b954 100644
--- a/samples/browseable/BluetoothAdvertisements/src/com.example.android.bluetoothadvertisements/ScanResultAdapter.java
+++ b/samples/browseable/BluetoothAdvertisements/src/com.example.android.bluetoothadvertisements/ScanResultAdapter.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2015 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.bluetoothadvertisements;
 
 import android.bluetooth.le.ScanResult;
@@ -59,7 +75,11 @@
 
         ScanResult scanResult = mArrayList.get(position);
 
-        deviceNameView.setText(scanResult.getDevice().getName());
+        String name = scanResult.getDevice().getName();
+        if (name == null) {
+            name = mContext.getResources().getString(R.string.no_name);
+        }
+        deviceNameView.setText(name);
         deviceAddressView.setText(scanResult.getDevice().getAddress());
         lastSeenView.setText(getTimeSinceString(mContext, scanResult.getTimestampNanos()));
 
diff --git a/samples/browseable/BluetoothAdvertisements/src/com.example.android.bluetoothadvertisements/ScannerFragment.java b/samples/browseable/BluetoothAdvertisements/src/com.example.android.bluetoothadvertisements/ScannerFragment.java
index b9ad4d9..4f5c2aa 100644
--- a/samples/browseable/BluetoothAdvertisements/src/com.example.android.bluetoothadvertisements/ScannerFragment.java
+++ b/samples/browseable/BluetoothAdvertisements/src/com.example.android.bluetoothadvertisements/ScannerFragment.java
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2015 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.bluetoothadvertisements;
 
 import android.bluetooth.BluetoothAdapter;
@@ -67,7 +83,7 @@
         // We could get a LayoutInflater from the ApplicationContext but it messes with the
         // default theme, so generate it from getActivity() and pass it in separately.
         mAdapter = new ScanResultAdapter(getActivity().getApplicationContext(),
-                                                    LayoutInflater.from(getActivity()));
+                LayoutInflater.from(getActivity()));
         mHandler = new Handler();
 
     }
@@ -164,6 +180,7 @@
         List<ScanFilter> scanFilters = new ArrayList<>();
 
         ScanFilter.Builder builder = new ScanFilter.Builder();
+        // Comment out the below line to see all BLE devices around you
         builder.setServiceUuid(Constants.Service_UUID);
         scanFilters.add(builder.build());
 
diff --git a/samples/browseable/BluetoothChat/res/values-v11/template-styles.xml b/samples/browseable/BluetoothChat/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/BluetoothChat/res/values-v11/template-styles.xml
+++ b/samples/browseable/BluetoothChat/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/BluetoothChat/res/values-v21/base-template-styles.xml b/samples/browseable/BluetoothChat/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/BluetoothChat/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/BluetoothChat/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/BluetoothChat/res/values/template-styles.xml b/samples/browseable/BluetoothChat/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/BluetoothChat/res/values/template-styles.xml
+++ b/samples/browseable/BluetoothChat/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/BluetoothLeGatt/res/values-v11/template-styles.xml b/samples/browseable/BluetoothLeGatt/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/BluetoothLeGatt/res/values-v11/template-styles.xml
+++ b/samples/browseable/BluetoothLeGatt/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/BluetoothLeGatt/res/values-v21/base-template-styles.xml b/samples/browseable/BluetoothLeGatt/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/BluetoothLeGatt/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/BluetoothLeGatt/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/BluetoothLeGatt/res/values/template-styles.xml b/samples/browseable/BluetoothLeGatt/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/BluetoothLeGatt/res/values/template-styles.xml
+++ b/samples/browseable/BluetoothLeGatt/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/BorderlessButtons/res/values-v11/template-styles.xml b/samples/browseable/BorderlessButtons/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/BorderlessButtons/res/values-v11/template-styles.xml
+++ b/samples/browseable/BorderlessButtons/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/BorderlessButtons/res/values-v21/base-template-styles.xml b/samples/browseable/BorderlessButtons/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/BorderlessButtons/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/BorderlessButtons/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/BorderlessButtons/res/values/template-styles.xml b/samples/browseable/BorderlessButtons/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/BorderlessButtons/res/values/template-styles.xml
+++ b/samples/browseable/BorderlessButtons/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/Camera2Basic/AndroidManifest.xml b/samples/browseable/Camera2Basic/AndroidManifest.xml
index 87d9af1..5b0b5b0 100644
--- a/samples/browseable/Camera2Basic/AndroidManifest.xml
+++ b/samples/browseable/Camera2Basic/AndroidManifest.xml
@@ -15,16 +15,14 @@
  limitations under the License.
 -->
 
-
-
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-    package="com.example.android.camera2basic"
-    android:versionCode="1"
-    android:versionName="1.0">
+    package="com.example.android.camera2basic">
 
-    <!-- Min/target SDK versions (<uses-sdk>) managed by build.gradle -->
     <uses-permission android:name="android.permission.CAMERA" />
 
+    <uses-feature android:name="android.hardware.camera" />
+    <uses-feature android:name="android.hardware.camera.autofocus" />
+
     <application android:allowBackup="true"
         android:label="@string/app_name"
         android:icon="@drawable/ic_launcher"
diff --git a/samples/browseable/Camera2Basic/res/layout-land/fragment_camera2_basic.xml b/samples/browseable/Camera2Basic/res/layout-land/fragment_camera2_basic.xml
index 3a3e2ff..8b2e1ad 100644
--- a/samples/browseable/Camera2Basic/res/layout-land/fragment_camera2_basic.xml
+++ b/samples/browseable/Camera2Basic/res/layout-land/fragment_camera2_basic.xml
@@ -26,14 +26,14 @@
         android:layout_alignParentTop="true" />
 
     <FrameLayout
+        android:id="@+id/control"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:layout_alignParentBottom="true"
         android:layout_alignParentEnd="true"
         android:layout_alignParentTop="true"
-        android:layout_below="@id/texture"
         android:layout_toRightOf="@id/texture"
-        android:background="#4285f4"
+        android:background="@color/control_background"
         android:orientation="horizontal">
 
         <Button
diff --git a/samples/browseable/Camera2Basic/res/layout/fragment_camera2_basic.xml b/samples/browseable/Camera2Basic/res/layout/fragment_camera2_basic.xml
index 7d05ab3..9c6dc65 100644
--- a/samples/browseable/Camera2Basic/res/layout/fragment_camera2_basic.xml
+++ b/samples/browseable/Camera2Basic/res/layout/fragment_camera2_basic.xml
@@ -25,12 +25,12 @@
         android:layout_alignParentTop="true" />
 
     <FrameLayout
+        android:id="@+id/control"
         android:layout_width="match_parent"
-        android:layout_height="wrap_content"
+        android:layout_height="112dp"
         android:layout_alignParentBottom="true"
         android:layout_alignParentStart="true"
-        android:layout_below="@id/texture"
-        android:background="#4285f4">
+        android:background="@color/control_background">
 
         <Button
             android:id="@+id/picture"
diff --git a/samples/browseable/Camera2Basic/res/values-v11/template-styles.xml b/samples/browseable/Camera2Basic/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/Camera2Basic/res/values-v11/template-styles.xml
+++ b/samples/browseable/Camera2Basic/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/Camera2Basic/res/values-v21/base-template-styles.xml b/samples/browseable/Camera2Basic/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/Camera2Basic/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/Camera2Basic/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/Camera2Basic/res/values/colors.xml b/samples/browseable/Camera2Basic/res/values/colors.xml
new file mode 100644
index 0000000..4b75d2b
--- /dev/null
+++ b/samples/browseable/Camera2Basic/res/values/colors.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright 2015 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.
+-->
+<resources>
+    <color name="control_background">#cc4285f4</color>
+</resources>
diff --git a/samples/browseable/Camera2Basic/res/values/template-styles.xml b/samples/browseable/Camera2Basic/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/Camera2Basic/res/values/template-styles.xml
+++ b/samples/browseable/Camera2Basic/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/Camera2Basic/src/com.example.android.camera2basic/Camera2BasicFragment.java b/samples/browseable/Camera2Basic/src/com.example.android.camera2basic/Camera2BasicFragment.java
index 2414ed6..020ca14 100644
--- a/samples/browseable/Camera2Basic/src/com.example.android.camera2basic/Camera2BasicFragment.java
+++ b/samples/browseable/Camera2Basic/src/com.example.android.camera2basic/Camera2BasicFragment.java
@@ -55,7 +55,6 @@
 import android.widget.Toast;
 
 import java.io.File;
-import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.nio.ByteBuffer;
@@ -264,14 +263,16 @@
                     break;
                 }
                 case STATE_WAITING_LOCK: {
-                    int afState = result.get(CaptureResult.CONTROL_AF_STATE);
-                    if (CaptureResult.CONTROL_AF_STATE_FOCUSED_LOCKED == afState ||
+                    Integer afState = result.get(CaptureResult.CONTROL_AF_STATE);
+                    if (afState == null) {
+                        captureStillPicture();
+                    } else if (CaptureResult.CONTROL_AF_STATE_FOCUSED_LOCKED == afState ||
                             CaptureResult.CONTROL_AF_STATE_NOT_FOCUSED_LOCKED == afState) {
                         // CONTROL_AE_STATE can be null on some devices
                         Integer aeState = result.get(CaptureResult.CONTROL_AE_STATE);
                         if (aeState == null ||
                                 aeState == CaptureResult.CONTROL_AE_STATE_CONVERGED) {
-                            mState = STATE_WAITING_NON_PRECAPTURE;
+                            mState = STATE_PICTURE_TAKEN;
                             captureStillPicture();
                         } else {
                             runPrecaptureSequence();
@@ -636,6 +637,8 @@
                     (float) viewWidth / mPreviewSize.getWidth());
             matrix.postScale(scale, scale, centerX, centerY);
             matrix.postRotate(90 * (rotation - 2), centerX, centerY);
+        } else if (Surface.ROTATION_180 == rotation) {
+            matrix.postRotate(180, centerX, centerY);
         }
         mTextureView.setTransform(matrix);
     }
@@ -657,7 +660,7 @@
                     CameraMetadata.CONTROL_AF_TRIGGER_START);
             // Tell #mCaptureCallback to wait for the lock.
             mState = STATE_WAITING_LOCK;
-            mCaptureSession.setRepeatingRequest(mPreviewRequestBuilder.build(), mCaptureCallback,
+            mCaptureSession.capture(mPreviewRequestBuilder.build(), mCaptureCallback,
                     mBackgroundHandler);
         } catch (CameraAccessException e) {
             e.printStackTrace();
@@ -794,8 +797,6 @@
             try {
                 output = new FileOutputStream(mFile);
                 output.write(bytes);
-            } catch (FileNotFoundException e) {
-                e.printStackTrace();
             } catch (IOException e) {
                 e.printStackTrace();
             } finally {
diff --git a/samples/browseable/Camera2Raw/res/values-v11/template-styles.xml b/samples/browseable/Camera2Raw/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/Camera2Raw/res/values-v11/template-styles.xml
+++ b/samples/browseable/Camera2Raw/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/Camera2Raw/res/values-v21/base-template-styles.xml b/samples/browseable/Camera2Raw/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/Camera2Raw/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/Camera2Raw/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/Camera2Raw/res/values/template-styles.xml b/samples/browseable/Camera2Raw/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/Camera2Raw/res/values/template-styles.xml
+++ b/samples/browseable/Camera2Raw/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/Camera2Video/res/values-v11/template-styles.xml b/samples/browseable/Camera2Video/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/Camera2Video/res/values-v11/template-styles.xml
+++ b/samples/browseable/Camera2Video/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/Camera2Video/res/values-v21/base-template-styles.xml b/samples/browseable/Camera2Video/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/Camera2Video/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/Camera2Video/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/Camera2Video/res/values/template-styles.xml b/samples/browseable/Camera2Video/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/Camera2Video/res/values/template-styles.xml
+++ b/samples/browseable/Camera2Video/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/CardEmulation/res/values-v11/template-styles.xml b/samples/browseable/CardEmulation/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/CardEmulation/res/values-v11/template-styles.xml
+++ b/samples/browseable/CardEmulation/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/CardEmulation/res/values-v21/base-template-styles.xml b/samples/browseable/CardEmulation/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/CardEmulation/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/CardEmulation/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/CardEmulation/res/values/template-styles.xml b/samples/browseable/CardEmulation/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/CardEmulation/res/values/template-styles.xml
+++ b/samples/browseable/CardEmulation/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/CardReader/res/values-v11/template-styles.xml b/samples/browseable/CardReader/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/CardReader/res/values-v11/template-styles.xml
+++ b/samples/browseable/CardReader/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/CardReader/res/values-v21/base-template-styles.xml b/samples/browseable/CardReader/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/CardReader/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/CardReader/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/CardReader/res/values/template-styles.xml b/samples/browseable/CardReader/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/CardReader/res/values/template-styles.xml
+++ b/samples/browseable/CardReader/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/CardView/res/values-v11/template-styles.xml b/samples/browseable/CardView/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/CardView/res/values-v11/template-styles.xml
+++ b/samples/browseable/CardView/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/CardView/res/values-v21/base-template-styles.xml b/samples/browseable/CardView/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/CardView/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/CardView/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/CardView/res/values/template-styles.xml b/samples/browseable/CardView/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/CardView/res/values/template-styles.xml
+++ b/samples/browseable/CardView/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/ClippingBasic/res/values-v11/template-styles.xml b/samples/browseable/ClippingBasic/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/ClippingBasic/res/values-v11/template-styles.xml
+++ b/samples/browseable/ClippingBasic/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/ClippingBasic/res/values-v21/base-template-styles.xml b/samples/browseable/ClippingBasic/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/ClippingBasic/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/ClippingBasic/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/ClippingBasic/res/values/template-styles.xml b/samples/browseable/ClippingBasic/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/ClippingBasic/res/values/template-styles.xml
+++ b/samples/browseable/ClippingBasic/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/ConfirmCredential/res/values-v11/template-styles.xml b/samples/browseable/ConfirmCredential/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/ConfirmCredential/res/values-v11/template-styles.xml
+++ b/samples/browseable/ConfirmCredential/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/ConfirmCredential/res/values-v21/base-template-styles.xml b/samples/browseable/ConfirmCredential/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/ConfirmCredential/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/ConfirmCredential/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/ConfirmCredential/res/values/template-styles.xml b/samples/browseable/ConfirmCredential/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/ConfirmCredential/res/values/template-styles.xml
+++ b/samples/browseable/ConfirmCredential/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/ConfirmCredential/src/com.example.android.confirmcredential/MainActivity.java b/samples/browseable/ConfirmCredential/src/com.example.android.confirmcredential/MainActivity.java
index b8cf6e1..c19875a 100644
--- a/samples/browseable/ConfirmCredential/src/com.example.android.confirmcredential/MainActivity.java
+++ b/samples/browseable/ConfirmCredential/src/com.example.android.confirmcredential/MainActivity.java
@@ -95,7 +95,7 @@
      * Tries to encrypt some data with the generated key in {@link #createKey} which is
      * only works if the user has just authenticated via device credentials.
      */
-    private void tryEncrypt() {
+    private boolean tryEncrypt() {
         try {
             KeyStore keyStore = KeyStore.getInstance("AndroidKeyStore");
             keyStore.load(null);
@@ -111,15 +111,18 @@
 
             // If the user has recently authenticated, you will reach here.
             showAlreadyAuthenticated();
+            return true;
         } catch (UserNotAuthenticatedException e) {
             // User is not authenticated, let's authenticate with device credentials.
             showAuthenticationScreen();
+            return false;
         } catch (KeyPermanentlyInvalidatedException e) {
             // This happens if the lock screen has been disabled or reset after the key was
             // generated after the key was generated.
             Toast.makeText(this, "Keys are invalidated after created. Retry the purchase\n"
                             + e.getMessage(),
                     Toast.LENGTH_LONG).show();
+            return false;
         } catch (BadPaddingException | IllegalBlockSizeException | KeyStoreException |
                 CertificateException | UnrecoverableKeyException | IOException
                 | NoSuchPaddingException | NoSuchAlgorithmException | InvalidKeyException e) {
@@ -172,7 +175,9 @@
         if (requestCode == REQUEST_CODE_CONFIRM_DEVICE_CREDENTIALS) {
             // Challenge completed, proceed with using cipher
             if (resultCode == RESULT_OK) {
-                showPurchaseConfirmation();
+                if (tryEncrypt()) {
+                    showPurchaseConfirmation();
+                }
             } else {
                 // The user canceled or didn’t complete the lock screen
                 // operation. Go to error/cancellation flow.
diff --git a/samples/browseable/CustomChoiceList/res/values-v11/template-styles.xml b/samples/browseable/CustomChoiceList/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/CustomChoiceList/res/values-v11/template-styles.xml
+++ b/samples/browseable/CustomChoiceList/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/CustomChoiceList/res/values-v21/base-template-styles.xml b/samples/browseable/CustomChoiceList/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/CustomChoiceList/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/CustomChoiceList/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/CustomChoiceList/res/values/template-styles.xml b/samples/browseable/CustomChoiceList/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/CustomChoiceList/res/values/template-styles.xml
+++ b/samples/browseable/CustomChoiceList/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/CustomNotifications/res/values-v11/template-styles.xml b/samples/browseable/CustomNotifications/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/CustomNotifications/res/values-v11/template-styles.xml
+++ b/samples/browseable/CustomNotifications/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/CustomNotifications/res/values-v21/base-template-styles.xml b/samples/browseable/CustomNotifications/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/CustomNotifications/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/CustomNotifications/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/CustomNotifications/res/values/template-styles.xml b/samples/browseable/CustomNotifications/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/CustomNotifications/res/values/template-styles.xml
+++ b/samples/browseable/CustomNotifications/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/CustomTransition/res/values-v11/template-styles.xml b/samples/browseable/CustomTransition/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/CustomTransition/res/values-v11/template-styles.xml
+++ b/samples/browseable/CustomTransition/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/CustomTransition/res/values-v21/base-template-styles.xml b/samples/browseable/CustomTransition/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/CustomTransition/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/CustomTransition/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/CustomTransition/res/values/template-styles.xml b/samples/browseable/CustomTransition/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/CustomTransition/res/values/template-styles.xml
+++ b/samples/browseable/CustomTransition/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/DataLayer/Application/res/values-v11/template-styles.xml b/samples/browseable/DataLayer/Application/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/DataLayer/Application/res/values-v11/template-styles.xml
+++ b/samples/browseable/DataLayer/Application/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/DataLayer/Application/res/values-v21/base-template-styles.xml b/samples/browseable/DataLayer/Application/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/DataLayer/Application/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/DataLayer/Application/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/DataLayer/Application/res/values/template-styles.xml b/samples/browseable/DataLayer/Application/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/DataLayer/Application/res/values/template-styles.xml
+++ b/samples/browseable/DataLayer/Application/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/DataLayer/Application/src/com.example.android.wearable.datalayer/MainActivity.java b/samples/browseable/DataLayer/Application/src/com.example.android.wearable.datalayer/MainActivity.java
index e6e4aa2..1c67c0e 100644
--- a/samples/browseable/DataLayer/Application/src/com.example.android.wearable.datalayer/MainActivity.java
+++ b/samples/browseable/DataLayer/Application/src/com.example.android.wearable.datalayer/MainActivity.java
@@ -216,8 +216,8 @@
     @Override //DataListener
     public void onDataChanged(DataEventBuffer dataEvents) {
         LOGD(TAG, "onDataChanged: " + dataEvents);
+        // Need to freeze the dataEvents so they will exist later on the UI thread
         final List<DataEvent> events = FreezableUtils.freezeIterable(dataEvents);
-        dataEvents.close();
         runOnUiThread(new Runnable() {
             @Override
             public void run() {
diff --git a/samples/browseable/DataLayer/Wearable/src/com.example.android.wearable.datalayer/DataLayerListenerService.java b/samples/browseable/DataLayer/Wearable/src/com.example.android.wearable.datalayer/DataLayerListenerService.java
index 34d3ca3..67dcef9 100644
--- a/samples/browseable/DataLayer/Wearable/src/com.example.android.wearable.datalayer/DataLayerListenerService.java
+++ b/samples/browseable/DataLayer/Wearable/src/com.example.android.wearable.datalayer/DataLayerListenerService.java
@@ -22,7 +22,6 @@
 
 import com.google.android.gms.common.ConnectionResult;
 import com.google.android.gms.common.api.GoogleApiClient;
-import com.google.android.gms.common.data.FreezableUtils;
 import com.google.android.gms.wearable.DataEvent;
 import com.google.android.gms.wearable.DataEventBuffer;
 import com.google.android.gms.wearable.MessageEvent;
@@ -59,8 +58,6 @@
     @Override
     public void onDataChanged(DataEventBuffer dataEvents) {
         LOGD(TAG, "onDataChanged: " + dataEvents);
-        final List<DataEvent> events = FreezableUtils.freezeIterable(dataEvents);
-        dataEvents.close();
         if (!mGoogleApiClient.isConnected() || !mGoogleApiClient.isConnecting()) {
             ConnectionResult connectionResult = mGoogleApiClient
                     .blockingConnect(30, TimeUnit.SECONDS);
@@ -72,7 +69,7 @@
         }
 
         // Loop through the events and send a message back to the node that created the data item.
-        for (DataEvent event : events) {
+        for (DataEvent event : dataEvents) {
             Uri uri = event.getDataItem().getUri();
             String path = uri.getPath();
             if (COUNT_PATH.equals(path)) {
diff --git a/samples/browseable/DataLayer/Wearable/src/com.example.android.wearable.datalayer/MainActivity.java b/samples/browseable/DataLayer/Wearable/src/com.example.android.wearable.datalayer/MainActivity.java
index 7d2a28c..678e428 100644
--- a/samples/browseable/DataLayer/Wearable/src/com.example.android.wearable.datalayer/MainActivity.java
+++ b/samples/browseable/DataLayer/Wearable/src/com.example.android.wearable.datalayer/MainActivity.java
@@ -42,7 +42,6 @@
 import com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks;
 import com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener;
 import com.google.android.gms.common.api.ResultCallback;
-import com.google.android.gms.common.data.FreezableUtils;
 import com.google.android.gms.wearable.Asset;
 import com.google.android.gms.wearable.CapabilityApi;
 import com.google.android.gms.wearable.CapabilityInfo;
@@ -151,9 +150,7 @@
     public void onDataChanged(DataEventBuffer dataEvents) {
         LOGD(TAG, "onDataChanged(): " + dataEvents);
 
-        final List<DataEvent> events = FreezableUtils.freezeIterable(dataEvents);
-        dataEvents.close();
-        for (DataEvent event : events) {
+        for (DataEvent event : dataEvents) {
             if (event.getType() == DataEvent.TYPE_CHANGED) {
                 String path = event.getDataItem().getUri().getPath();
                 if (DataLayerListenerService.IMAGE_PATH.equals(path)) {
diff --git a/samples/browseable/DelayedConfirmation/Application/res/values-v11/template-styles.xml b/samples/browseable/DelayedConfirmation/Application/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/DelayedConfirmation/Application/res/values-v11/template-styles.xml
+++ b/samples/browseable/DelayedConfirmation/Application/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/DelayedConfirmation/Application/res/values-v21/base-template-styles.xml b/samples/browseable/DelayedConfirmation/Application/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/DelayedConfirmation/Application/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/DelayedConfirmation/Application/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/DelayedConfirmation/Application/res/values/template-styles.xml b/samples/browseable/DelayedConfirmation/Application/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/DelayedConfirmation/Application/res/values/template-styles.xml
+++ b/samples/browseable/DelayedConfirmation/Application/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/DeviceOwner/res/values-v11/template-styles.xml b/samples/browseable/DeviceOwner/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/DeviceOwner/res/values-v11/template-styles.xml
+++ b/samples/browseable/DeviceOwner/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/DeviceOwner/res/values-v21/base-template-styles.xml b/samples/browseable/DeviceOwner/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/DeviceOwner/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/DeviceOwner/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/DeviceOwner/res/values/template-styles.xml b/samples/browseable/DeviceOwner/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/DeviceOwner/res/values/template-styles.xml
+++ b/samples/browseable/DeviceOwner/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/DirectorySelection/res/values-v11/template-styles.xml b/samples/browseable/DirectorySelection/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/DirectorySelection/res/values-v11/template-styles.xml
+++ b/samples/browseable/DirectorySelection/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/DirectorySelection/res/values-v21/base-template-styles.xml b/samples/browseable/DirectorySelection/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/DirectorySelection/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/DirectorySelection/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/DirectorySelection/res/values/template-styles.xml b/samples/browseable/DirectorySelection/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/DirectorySelection/res/values/template-styles.xml
+++ b/samples/browseable/DirectorySelection/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/DisplayingBitmaps/res/values-v11/template-styles.xml b/samples/browseable/DisplayingBitmaps/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/DisplayingBitmaps/res/values-v11/template-styles.xml
+++ b/samples/browseable/DisplayingBitmaps/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/DisplayingBitmaps/res/values-v21/base-template-styles.xml b/samples/browseable/DisplayingBitmaps/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/DisplayingBitmaps/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/DisplayingBitmaps/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/DisplayingBitmaps/res/values/template-styles.xml b/samples/browseable/DisplayingBitmaps/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/DisplayingBitmaps/res/values/template-styles.xml
+++ b/samples/browseable/DisplayingBitmaps/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/DocumentCentricApps/res/values-v11/template-styles.xml b/samples/browseable/DocumentCentricApps/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/DocumentCentricApps/res/values-v11/template-styles.xml
+++ b/samples/browseable/DocumentCentricApps/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/DocumentCentricApps/res/values-v21/base-template-styles.xml b/samples/browseable/DocumentCentricApps/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/DocumentCentricApps/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/DocumentCentricApps/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/DocumentCentricApps/res/values/template-styles.xml b/samples/browseable/DocumentCentricApps/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/DocumentCentricApps/res/values/template-styles.xml
+++ b/samples/browseable/DocumentCentricApps/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/DocumentCentricRelinquishIdentity/res/values-v11/template-styles.xml b/samples/browseable/DocumentCentricRelinquishIdentity/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/DocumentCentricRelinquishIdentity/res/values-v11/template-styles.xml
+++ b/samples/browseable/DocumentCentricRelinquishIdentity/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/DocumentCentricRelinquishIdentity/res/values-v21/base-template-styles.xml b/samples/browseable/DocumentCentricRelinquishIdentity/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/DocumentCentricRelinquishIdentity/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/DocumentCentricRelinquishIdentity/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/DocumentCentricRelinquishIdentity/res/values/template-styles.xml b/samples/browseable/DocumentCentricRelinquishIdentity/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/DocumentCentricRelinquishIdentity/res/values/template-styles.xml
+++ b/samples/browseable/DocumentCentricRelinquishIdentity/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/DoneBar/res/values-v11/template-styles.xml b/samples/browseable/DoneBar/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/DoneBar/res/values-v11/template-styles.xml
+++ b/samples/browseable/DoneBar/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/DoneBar/res/values-v21/base-template-styles.xml b/samples/browseable/DoneBar/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/DoneBar/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/DoneBar/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/DrawableTinting/res/values-v11/template-styles.xml b/samples/browseable/DrawableTinting/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/DrawableTinting/res/values-v11/template-styles.xml
+++ b/samples/browseable/DrawableTinting/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/DrawableTinting/res/values-v21/base-template-styles.xml b/samples/browseable/DrawableTinting/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/DrawableTinting/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/DrawableTinting/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/DrawableTinting/res/values/template-styles.xml b/samples/browseable/DrawableTinting/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/DrawableTinting/res/values/template-styles.xml
+++ b/samples/browseable/DrawableTinting/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/ElevationBasic/res/values-v11/template-styles.xml b/samples/browseable/ElevationBasic/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/ElevationBasic/res/values-v11/template-styles.xml
+++ b/samples/browseable/ElevationBasic/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/ElevationBasic/res/values-v21/base-template-styles.xml b/samples/browseable/ElevationBasic/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/ElevationBasic/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/ElevationBasic/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/ElevationBasic/res/values/template-styles.xml b/samples/browseable/ElevationBasic/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/ElevationBasic/res/values/template-styles.xml
+++ b/samples/browseable/ElevationBasic/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/ElevationDrag/res/values-v11/template-styles.xml b/samples/browseable/ElevationDrag/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/ElevationDrag/res/values-v11/template-styles.xml
+++ b/samples/browseable/ElevationDrag/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/ElevationDrag/res/values-v21/base-template-styles.xml b/samples/browseable/ElevationDrag/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/ElevationDrag/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/ElevationDrag/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/ElevationDrag/res/values/template-styles.xml b/samples/browseable/ElevationDrag/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/ElevationDrag/res/values/template-styles.xml
+++ b/samples/browseable/ElevationDrag/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/ElizaChat/res/values-v11/template-styles.xml b/samples/browseable/ElizaChat/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/ElizaChat/res/values-v11/template-styles.xml
+++ b/samples/browseable/ElizaChat/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/ElizaChat/res/values-v21/base-template-styles.xml b/samples/browseable/ElizaChat/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/ElizaChat/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/ElizaChat/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/ElizaChat/res/values/template-styles.xml b/samples/browseable/ElizaChat/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/ElizaChat/res/values/template-styles.xml
+++ b/samples/browseable/ElizaChat/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/ElizaChat/src/com.example.android.wearable.elizachat/MainActivity.java b/samples/browseable/ElizaChat/src/com.example.android.wearable.elizachat/MainActivity.java
index 982e3de..2e132a8 100644
--- a/samples/browseable/ElizaChat/src/com.example.android.wearable.elizachat/MainActivity.java
+++ b/samples/browseable/ElizaChat/src/com.example.android.wearable.elizachat/MainActivity.java
@@ -55,11 +55,12 @@
             }
         };
         mHistoryView = (TextView) findViewById(R.id.history);
-        startResponderService();
+        startResponderService(ResponderService.ACTION_INCOMING);
     }
 
-    private void startResponderService() {
-        Intent serviceIntent = new Intent(ResponderService.ACTION_INCOMING);
+    private void startResponderService(String action) {
+        Intent serviceIntent = new Intent(this, ResponderService.class);
+        serviceIntent.setAction(action);
         startService(serviceIntent);
     }
 
@@ -69,9 +70,7 @@
         LocalBroadcastManager.getInstance(this).registerReceiver(mReceiver,
                 new IntentFilter(ACTION_NOTIFY));
         mHistoryView.setText("");
-        Intent serviceIntent = new Intent(ACTION_GET_CONVERSATION);
-        startService(serviceIntent);
-
+        startResponderService(ACTION_GET_CONVERSATION);
     }
 
     @Override
diff --git a/samples/browseable/FindMyPhone/Application/res/values-v11/template-styles.xml b/samples/browseable/FindMyPhone/Application/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/FindMyPhone/Application/res/values-v11/template-styles.xml
+++ b/samples/browseable/FindMyPhone/Application/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/FindMyPhone/Application/res/values-v21/base-template-styles.xml b/samples/browseable/FindMyPhone/Application/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/FindMyPhone/Application/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/FindMyPhone/Application/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/FindMyPhone/Application/res/values/template-styles.xml b/samples/browseable/FindMyPhone/Application/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/FindMyPhone/Application/res/values/template-styles.xml
+++ b/samples/browseable/FindMyPhone/Application/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/FindMyPhone/Application/src/com.example.android.wearable.findphone/SoundAlarmListenerService.java b/samples/browseable/FindMyPhone/Application/src/com.example.android.wearable.findphone/SoundAlarmListenerService.java
index c89db9d..3de7501 100644
--- a/samples/browseable/FindMyPhone/Application/src/com.example.android.wearable.findphone/SoundAlarmListenerService.java
+++ b/samples/browseable/FindMyPhone/Application/src/com.example.android.wearable.findphone/SoundAlarmListenerService.java
@@ -95,7 +95,6 @@
                 }
             }
         }
-        dataEvents.close();
     }
 
 }
diff --git a/samples/browseable/FindMyPhone/Wearable/src/com.example.android.wearable.findphone/FindPhoneService.java b/samples/browseable/FindMyPhone/Wearable/src/com.example.android.wearable.findphone/FindPhoneService.java
index 97204b4..c6c6d67 100644
--- a/samples/browseable/FindMyPhone/Wearable/src/com.example.android.wearable.findphone/FindPhoneService.java
+++ b/samples/browseable/FindMyPhone/Wearable/src/com.example.android.wearable.findphone/FindPhoneService.java
@@ -73,19 +73,22 @@
             if (intent.getAction().equals(ACTION_TOGGLE_ALARM)) {
                 // Get current state of the alarm.
                 DataItemBuffer result = Wearable.DataApi.getDataItems(mGoogleApiClient).await();
-                if (result.getStatus().isSuccess()) {
-                    if (result.getCount() == 1) {
-                        alarmOn = DataMap.fromByteArray(result.get(0).getData())
-                                .getBoolean(FIELD_ALARM_ON, false);
-                    } else {
-                        Log.e(TAG, "Unexpected number of DataItems found.\n"
-                                + "\tExpected: 1\n"
-                                + "\tActual: " + result.getCount());
+                try {
+                    if (result.getStatus().isSuccess()) {
+                        if (result.getCount() == 1) {
+                            alarmOn = DataMap.fromByteArray(result.get(0).getData())
+                                    .getBoolean(FIELD_ALARM_ON, false);
+                        } else {
+                            Log.e(TAG, "Unexpected number of DataItems found.\n"
+                                    + "\tExpected: 1\n"
+                                    + "\tActual: " + result.getCount());
+                        }
+                    } else if (Log.isLoggable(TAG, Log.DEBUG)) {
+                        Log.d(TAG, "onHandleIntent: failed to get current alarm state");
                     }
-                } else if (Log.isLoggable(TAG, Log.DEBUG)) {
-                    Log.d(TAG, "onHandleIntent: failed to get current alarm state");
+                } finally {
+                    result.release();
                 }
-                result.close();
                 // Toggle alarm.
                 alarmOn = !alarmOn;
                 // Change notification text based on new value of alarmOn.
diff --git a/samples/browseable/FingerprintDialog/AndroidManifest.xml b/samples/browseable/FingerprintDialog/AndroidManifest.xml
index 5f754ad..3b19fbe 100644
--- a/samples/browseable/FingerprintDialog/AndroidManifest.xml
+++ b/samples/browseable/FingerprintDialog/AndroidManifest.xml
@@ -35,7 +35,9 @@
                 <category android:name="android.intent.category.LAUNCHER"/>
             </intent-filter>
         </activity>
+
+        <activity
+            android:name=".SettingsActivity"
+            android:label="@string/action_settings" />
     </application>
-
-
 </manifest>
diff --git a/samples/browseable/FingerprintDialog/res/layout/fingerprint_dialog_backup.xml b/samples/browseable/FingerprintDialog/res/layout/fingerprint_dialog_backup.xml
index 0b88e33..2be05b1 100644
--- a/samples/browseable/FingerprintDialog/res/layout/fingerprint_dialog_backup.xml
+++ b/samples/browseable/FingerprintDialog/res/layout/fingerprint_dialog_backup.xml
@@ -16,21 +16,37 @@
   -->
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/backup_container"
-    android:layout_width="match_parent" android:layout_height="match_parent"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
     android:paddingTop="16dp"
     android:paddingBottom="8dp">
 
-    <TextView
+    <FrameLayout
+        android:id="@+id/description"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:textAppearance="@android:style/TextAppearance.Material.Subhead"
-        android:text="@string/password_description"
-        android:id="@+id/description"
         android:layout_alignParentTop="true"
         android:layout_alignParentStart="true"
         android:layout_marginStart="24dp"
         android:layout_marginEnd="24dp"
-        android:textColor="?android:attr/textColorSecondary"/>
+        >
+        <TextView
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:textAppearance="@android:style/TextAppearance.Material.Subhead"
+            android:text="@string/password_description"
+            android:id="@+id/password_description"
+            android:textColor="?android:attr/textColorSecondary" />
+
+        <TextView
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:textAppearance="@android:style/TextAppearance.Material.Subhead"
+            android:text="@string/new_fingerprint_enrolled_description"
+            android:id="@+id/new_fingerprint_enrolled_description"
+            android:visibility="gone"
+            android:textColor="?android:attr/textColorSecondary" />
+    </FrameLayout>
 
     <EditText
         android:layout_width="wrap_content"
@@ -46,4 +62,17 @@
         android:layout_marginEnd="20dp"
         android:layout_alignParentStart="true" />
 
+    <CheckBox
+        android:id="@+id/use_fingerprint_in_future_check"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_below="@+id/password"
+        android:layout_alignParentStart="true"
+        android:layout_marginTop="16dp"
+        android:layout_marginStart="20dp"
+        android:layout_marginEnd="20dp"
+        android:checked="true"
+        android:visibility="gone"
+        android:text="@string/use_fingerprint_in_future" />
+
 </RelativeLayout>
\ No newline at end of file
diff --git a/samples/browseable/FingerprintDialog/res/layout/fingerprint_dialog_content.xml b/samples/browseable/FingerprintDialog/res/layout/fingerprint_dialog_content.xml
index b56ccbb..3929eba 100644
--- a/samples/browseable/FingerprintDialog/res/layout/fingerprint_dialog_content.xml
+++ b/samples/browseable/FingerprintDialog/res/layout/fingerprint_dialog_content.xml
@@ -19,8 +19,8 @@
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:paddingBottom="8dp"
-    android:paddingLeft="24dp"
-    android:paddingRight="24dp"
+    android:paddingStart="24dp"
+    android:paddingEnd="24dp"
     android:paddingTop="16dp">
 
     <TextView
@@ -50,7 +50,7 @@
         android:layout_height="wrap_content"
         android:layout_alignBottom="@+id/fingerprint_icon"
         android:layout_alignTop="@+id/fingerprint_icon"
-        android:layout_marginLeft="16dp"
+        android:layout_marginStart="16dp"
         android:layout_toEndOf="@+id/fingerprint_icon"
         android:gravity="center_vertical"
         android:text="@string/fingerprint_hint"
diff --git a/samples/browseable/FingerprintDialog/res/menu/menu_main.xml b/samples/browseable/FingerprintDialog/res/menu/menu_main.xml
new file mode 100644
index 0000000..73f5e89
--- /dev/null
+++ b/samples/browseable/FingerprintDialog/res/menu/menu_main.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Copyright (C) 2015 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
+  -->
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools" tools:context=".MainActivity">
+    <item android:id="@+id/action_settings" android:title="@string/action_settings"
+        android:orderInCategory="100" android:showAsAction="never" />
+</menu>
diff --git a/samples/browseable/FingerprintDialog/res/values-v11/template-styles.xml b/samples/browseable/FingerprintDialog/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/FingerprintDialog/res/values-v11/template-styles.xml
+++ b/samples/browseable/FingerprintDialog/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/FingerprintDialog/res/values-v21/base-template-styles.xml b/samples/browseable/FingerprintDialog/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/FingerprintDialog/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/FingerprintDialog/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/FingerprintDialog/res/values/strings.xml b/samples/browseable/FingerprintDialog/res/values/strings.xml
index 8a6ecde..9f5a6fd 100644
--- a/samples/browseable/FingerprintDialog/res/values/strings.xml
+++ b/samples/browseable/FingerprintDialog/res/values/strings.xml
@@ -31,4 +31,8 @@
     <string name="item_price">$62.68</string>
     <string name="item_description">Mesh backpack in white. Black textile trim throughout.</string>
     <string name="purchase_done">Purchase successful</string>
+    <string name="new_fingerprint_enrolled_description">A new fingerprint was added to this device, so your password is required.</string>
+    <string name="use_fingerprint_in_future">Use fingerprint in the future</string>
+    <string name="use_fingerprint_to_authenticate_title">Use fingerprint to authenticate</string>
+    <string name="use_fingerprint_to_authenticate_key" >use_fingerprint_to_authenticate_key</string>
 </resources>
diff --git a/samples/browseable/FingerprintDialog/res/values/template-styles.xml b/samples/browseable/FingerprintDialog/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/FingerprintDialog/res/values/template-styles.xml
+++ b/samples/browseable/FingerprintDialog/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/FingerprintDialog/res/xml/preferences.xml b/samples/browseable/FingerprintDialog/res/xml/preferences.xml
new file mode 100644
index 0000000..761391d
--- /dev/null
+++ b/samples/browseable/FingerprintDialog/res/xml/preferences.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Copyright (C) 2015 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
+  -->
+<PreferenceScreen  xmlns:android="http://schemas.android.com/apk/res/android">
+    <CheckBoxPreference
+        android:key="@string/use_fingerprint_to_authenticate_key"
+        android:title="@string/use_fingerprint_to_authenticate_title"
+        android:persistent="true"
+        android:defaultValue="true" />
+</PreferenceScreen>
\ No newline at end of file
diff --git a/samples/browseable/FingerprintDialog/src/com.example.android.fingerprintdialog/FingerprintAuthenticationDialogFragment.java b/samples/browseable/FingerprintDialog/src/com.example.android.fingerprintdialog/FingerprintAuthenticationDialogFragment.java
index 57c00de..b17ebb0 100644
--- a/samples/browseable/FingerprintDialog/src/com.example.android.fingerprintdialog/FingerprintAuthenticationDialogFragment.java
+++ b/samples/browseable/FingerprintDialog/src/com.example.android.fingerprintdialog/FingerprintAuthenticationDialogFragment.java
@@ -16,7 +16,9 @@
 
 package com.example.android.fingerprintdialog;
 
+import android.app.Activity;
 import android.app.DialogFragment;
+import android.content.SharedPreferences;
 import android.hardware.fingerprint.FingerprintManager;
 import android.os.Bundle;
 import android.view.KeyEvent;
@@ -26,6 +28,7 @@
 import android.view.inputmethod.EditorInfo;
 import android.view.inputmethod.InputMethodManager;
 import android.widget.Button;
+import android.widget.CheckBox;
 import android.widget.EditText;
 import android.widget.ImageView;
 import android.widget.TextView;
@@ -44,14 +47,19 @@
     private View mFingerprintContent;
     private View mBackupContent;
     private EditText mPassword;
+    private CheckBox mUseFingerprintFutureCheckBox;
+    private TextView mPasswordDescriptionTextView;
+    private TextView mNewFingerprintEnrolledTextView;
 
     private Stage mStage = Stage.FINGERPRINT;
 
     private FingerprintManager.CryptoObject mCryptoObject;
     private FingerprintUiHelper mFingerprintUiHelper;
+    private MainActivity mActivity;
 
     @Inject FingerprintUiHelper.FingerprintUiHelperBuilder mFingerprintUiHelperBuilder;
     @Inject InputMethodManager mInputMethodManager;
+    @Inject SharedPreferences mSharedPreferences;
 
     @Inject
     public FingerprintAuthenticationDialogFragment() {}
@@ -93,6 +101,11 @@
         mBackupContent = v.findViewById(R.id.backup_container);
         mPassword = (EditText) v.findViewById(R.id.password);
         mPassword.setOnEditorActionListener(this);
+        mPasswordDescriptionTextView = (TextView) v.findViewById(R.id.password_description);
+        mUseFingerprintFutureCheckBox = (CheckBox)
+                v.findViewById(R.id.use_fingerprint_in_future_check);
+        mNewFingerprintEnrolledTextView = (TextView)
+                v.findViewById(R.id.new_fingerprint_enrolled_description);
         mFingerprintUiHelper = mFingerprintUiHelperBuilder.build(
                 (ImageView) v.findViewById(R.id.fingerprint_icon),
                 (TextView) v.findViewById(R.id.fingerprint_status), this);
@@ -114,12 +127,22 @@
         }
     }
 
+    public void setStage(Stage stage) {
+        mStage = stage;
+    }
+
     @Override
     public void onPause() {
         super.onPause();
         mFingerprintUiHelper.stopListening();
     }
 
+    @Override
+    public void onAttach(Activity activity) {
+        super.onAttach(activity);
+        mActivity = (MainActivity) activity;
+    }
+
     /**
      * Sets the crypto object to be passed in when authenticating with fingerprint.
      */
@@ -149,12 +172,24 @@
      * let's the activity know about the result.
      */
     private void verifyPassword() {
-        if (checkPassword(mPassword.getText().toString())) {
-            ((MainActivity) getActivity()).onPurchased(false /* without Fingerprint */);
-            dismiss();
-        } else {
-            // assume the password is always correct.
+        if (!checkPassword(mPassword.getText().toString())) {
+            return;
         }
+        if (mStage == Stage.NEW_FINGERPRINT_ENROLLED) {
+            SharedPreferences.Editor editor = mSharedPreferences.edit();
+            editor.putBoolean(getString(R.string.use_fingerprint_to_authenticate_key),
+                    mUseFingerprintFutureCheckBox.isChecked());
+            editor.apply();
+
+            if (mUseFingerprintFutureCheckBox.isChecked()) {
+                // Re-create the key so that fingerprints including new ones are validated.
+                mActivity.createKey();
+                mStage = Stage.FINGERPRINT;
+            }
+        }
+        mPassword.setText("");
+        mActivity.onPurchased(false /* without Fingerprint */);
+        dismiss();
     }
 
     /**
@@ -181,11 +216,18 @@
                 mFingerprintContent.setVisibility(View.VISIBLE);
                 mBackupContent.setVisibility(View.GONE);
                 break;
+            case NEW_FINGERPRINT_ENROLLED:
+                // Intentional fall through
             case PASSWORD:
                 mCancelButton.setText(R.string.cancel);
                 mSecondDialogButton.setText(R.string.ok);
                 mFingerprintContent.setVisibility(View.GONE);
                 mBackupContent.setVisibility(View.VISIBLE);
+                if (mStage == Stage.NEW_FINGERPRINT_ENROLLED) {
+                    mPasswordDescriptionTextView.setVisibility(View.GONE);
+                    mNewFingerprintEnrolledTextView.setVisibility(View.VISIBLE);
+                    mUseFingerprintFutureCheckBox.setVisibility(View.VISIBLE);
+                }
                 break;
         }
     }
@@ -203,7 +245,7 @@
     public void onAuthenticated() {
         // Callback from FingerprintUiHelper. Let the activity know that authentication was
         // successful.
-        ((MainActivity) getActivity()).onPurchased(true /* withFingerprint */);
+        mActivity.onPurchased(true /* withFingerprint */);
         dismiss();
     }
 
@@ -215,8 +257,9 @@
     /**
      * Enumeration to indicate which authentication method the user is trying to authenticate with.
      */
-    private enum Stage {
+    public enum Stage {
         FINGERPRINT,
+        NEW_FINGERPRINT_ENROLLED,
         PASSWORD
     }
 }
diff --git a/samples/browseable/FingerprintDialog/src/com.example.android.fingerprintdialog/FingerprintModule.java b/samples/browseable/FingerprintDialog/src/com.example.android.fingerprintdialog/FingerprintModule.java
index 16d5067..964e1f6 100644
--- a/samples/browseable/FingerprintDialog/src/com.example.android.fingerprintdialog/FingerprintModule.java
+++ b/samples/browseable/FingerprintDialog/src/com.example.android.fingerprintdialog/FingerprintModule.java
@@ -18,7 +18,10 @@
 
 import android.app.KeyguardManager;
 import android.content.Context;
+import android.content.SharedPreferences;
 import android.hardware.fingerprint.FingerprintManager;
+import android.preference.PreferenceManager;
+import android.security.keystore.KeyProperties;
 import android.view.inputmethod.InputMethodManager;
 
 import java.security.KeyStore;
@@ -75,7 +78,7 @@
     @Provides
     public KeyGenerator providesKeyGenerator() {
         try {
-            return KeyGenerator.getInstance("AES", "AndroidKeyStore");
+            return KeyGenerator.getInstance(KeyProperties.KEY_ALGORITHM_AES, "AndroidKeyStore");
         } catch (NoSuchAlgorithmException | NoSuchProviderException e) {
             throw new RuntimeException("Failed to get an instance of KeyGenerator", e);
         }
@@ -84,7 +87,9 @@
     @Provides
     public Cipher providesCipher(KeyStore keyStore) {
         try {
-            return Cipher.getInstance("AES/CBC/PKCS7Padding");
+            return Cipher.getInstance(KeyProperties.KEY_ALGORITHM_AES + "/"
+                    + KeyProperties.BLOCK_MODE_CBC + "/"
+                    + KeyProperties.ENCRYPTION_PADDING_PKCS7);
         } catch (NoSuchAlgorithmException | NoSuchPaddingException e) {
             throw new RuntimeException("Failed to get an instance of Cipher", e);
         }
@@ -94,4 +99,9 @@
     public InputMethodManager providesInputMethodManager(Context context) {
         return (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
     }
+
+    @Provides
+    public SharedPreferences providesSharedPreferences(Context context) {
+        return PreferenceManager.getDefaultSharedPreferences(context);
+    }
 }
diff --git a/samples/browseable/FingerprintDialog/src/com.example.android.fingerprintdialog/FingerprintUiHelper.java b/samples/browseable/FingerprintDialog/src/com.example.android.fingerprintdialog/FingerprintUiHelper.java
index ab7570c..92fcdb1 100644
--- a/samples/browseable/FingerprintDialog/src/com.example.android.fingerprintdialog/FingerprintUiHelper.java
+++ b/samples/browseable/FingerprintDialog/src/com.example.android.fingerprintdialog/FingerprintUiHelper.java
@@ -82,7 +82,8 @@
         }
         mCancellationSignal = new CancellationSignal();
         mSelfCancelled = false;
-        mFingerprintManager.authenticate(cryptoObject, mCancellationSignal, this, 0 /* flags */);
+        mFingerprintManager
+                .authenticate(cryptoObject, mCancellationSignal, 0 /* flags */, this, null);
         mIcon.setImageResource(R.drawable.ic_fp_40px);
     }
 
diff --git a/samples/browseable/FingerprintDialog/src/com.example.android.fingerprintdialog/MainActivity.java b/samples/browseable/FingerprintDialog/src/com.example.android.fingerprintdialog/MainActivity.java
index 9d09765..c954bfa 100644
--- a/samples/browseable/FingerprintDialog/src/com.example.android.fingerprintdialog/MainActivity.java
+++ b/samples/browseable/FingerprintDialog/src/com.example.android.fingerprintdialog/MainActivity.java
@@ -19,6 +19,8 @@
 import android.Manifest;
 import android.app.Activity;
 import android.app.KeyguardManager;
+import android.content.Intent;
+import android.content.SharedPreferences;
 import android.content.pm.PackageManager;
 import android.hardware.fingerprint.FingerprintManager;
 import android.os.Bundle;
@@ -27,6 +29,8 @@
 import android.security.keystore.KeyProperties;
 import android.util.Base64;
 import android.util.Log;
+import android.view.Menu;
+import android.view.MenuItem;
 import android.view.View;
 import android.widget.Button;
 import android.widget.TextView;
@@ -60,23 +64,29 @@
     /** Alias for our key in the Android Key Store */
     private static final String KEY_NAME = "my_key";
 
+    private static final int FINGERPRINT_PERMISSION_REQUEST_CODE = 0;
+
     @Inject KeyguardManager mKeyguardManager;
+    @Inject FingerprintManager mFingerprintManager;
     @Inject FingerprintAuthenticationDialogFragment mFragment;
     @Inject KeyStore mKeyStore;
     @Inject KeyGenerator mKeyGenerator;
     @Inject Cipher mCipher;
+    @Inject SharedPreferences mSharedPreferences;
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         ((InjectedApplication) getApplication()).inject(this);
 
-        requestPermissions(new String[]{Manifest.permission.USE_FINGERPRINT}, 0);
+        requestPermissions(new String[]{Manifest.permission.USE_FINGERPRINT},
+                FINGERPRINT_PERMISSION_REQUEST_CODE);
     }
 
     @Override
     public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] state) {
-        if (requestCode == 0 && state[0] == PackageManager.PERMISSION_GRANTED) {
+        if (requestCode == FINGERPRINT_PERMISSION_REQUEST_CODE
+                && state[0] == PackageManager.PERMISSION_GRANTED) {
             setContentView(R.layout.activity_main);
             Button purchaseButton = (Button) findViewById(R.id.purchase_button);
             if (!mKeyguardManager.isKeyguardSecure()) {
@@ -88,35 +98,71 @@
                 purchaseButton.setEnabled(false);
                 return;
             }
+            if (!mFingerprintManager.hasEnrolledFingerprints()) {
+                purchaseButton.setEnabled(false);
+                // This happens when no fingerprints are registered.
+                Toast.makeText(this,
+                        "Go to 'Settings -> Security -> Fingerprint' and register at least one fingerprint",
+                        Toast.LENGTH_LONG).show();
+                return;
+            }
             createKey();
+            purchaseButton.setEnabled(true);
             purchaseButton.setOnClickListener(new View.OnClickListener() {
                 @Override
                 public void onClick(View v) {
+                    findViewById(R.id.confirmation_message).setVisibility(View.GONE);
+                    findViewById(R.id.encrypted_message).setVisibility(View.GONE);
 
-                    // Show the fingerprint dialog. The user has the option to use the fingerprint with
-                    // crypto, or you can fall back to using a server-side verified password.
-                    mFragment.setCryptoObject(new FingerprintManager.CryptoObject(mCipher));
-                    mFragment.show(getFragmentManager(), DIALOG_FRAGMENT_TAG);
+                    // Set up the crypto object for later. The object will be authenticated by use
+                    // of the fingerprint.
+                    if (initCipher()) {
+
+                        // Show the fingerprint dialog. The user has the option to use the fingerprint with
+                        // crypto, or you can fall back to using a server-side verified password.
+                        mFragment.setCryptoObject(new FingerprintManager.CryptoObject(mCipher));
+                        boolean useFingerprintPreference = mSharedPreferences
+                                .getBoolean(getString(R.string.use_fingerprint_to_authenticate_key),
+                                        true);
+                        if (useFingerprintPreference) {
+                            mFragment.setStage(
+                                    FingerprintAuthenticationDialogFragment.Stage.FINGERPRINT);
+                        } else {
+                            mFragment.setStage(
+                                    FingerprintAuthenticationDialogFragment.Stage.PASSWORD);
+                        }
+                        mFragment.show(getFragmentManager(), DIALOG_FRAGMENT_TAG);
+                    } else {
+                        // This happens if the lock screen has been disabled or or a fingerprint got
+                        // enrolled. Thus show the dialog to authenticate with their password first
+                        // and ask the user if they want to authenticate with fingerprints in the
+                        // future
+                        mFragment.setCryptoObject(new FingerprintManager.CryptoObject(mCipher));
+                        mFragment.setStage(
+                                FingerprintAuthenticationDialogFragment.Stage.NEW_FINGERPRINT_ENROLLED);
+                        mFragment.show(getFragmentManager(), DIALOG_FRAGMENT_TAG);
+                    }
                 }
             });
-
-            // Set up the crypto object for later. The object will be authenticated by use
-            // of the fingerprint.
-            initCipher();
         }
     }
 
-    private void initCipher() {
+    /**
+     * Initialize the {@link Cipher} instance with the created key in the {@link #createKey()}
+     * method.
+     *
+     * @return {@code true} if initialization is successful, {@code false} if the lock screen has
+     * been disabled or reset after the key was generated, or if a fingerprint got enrolled after
+     * the key was generated.
+     */
+    private boolean initCipher() {
         try {
             mKeyStore.load(null);
             SecretKey key = (SecretKey) mKeyStore.getKey(KEY_NAME, null);
             mCipher.init(Cipher.ENCRYPT_MODE, key);
+            return true;
         } catch (KeyPermanentlyInvalidatedException e) {
-            // This happens if the lock screen has been disabled or reset after the key was
-            // generated, or if a fingerprint got enrolled after the key was generated.
-            Toast.makeText(this, "Keys are invalidated after created. Retry the purchase\n"
-                            + e.getMessage(),
-                    Toast.LENGTH_LONG).show();
+            return false;
         } catch (KeyStoreException | CertificateException | UnrecoverableKeyException | IOException
                 | NoSuchAlgorithmException | InvalidKeyException e) {
             throw new RuntimeException("Failed to init Cipher", e);
@@ -124,7 +170,6 @@
     }
 
     public void onPurchased(boolean withFingerprint) {
-        findViewById(R.id.purchase_button).setVisibility(View.GONE);
         if (withFingerprint) {
             // If the user has authenticated with fingerprint, verify that using cryptography and
             // then show the confirmation message.
@@ -164,7 +209,7 @@
      * Creates a symmetric key in the Android Key Store which can only be used after the user has
      * authenticated with fingerprint.
      */
-    private void createKey() {
+    public void createKey() {
         // The enrolling flow for fingerprint. This is where you ask the user to set up fingerprint
         // for your flow. Use of keys is necessary if you need to know if the set of
         // enrolled fingerprints has changed.
@@ -187,4 +232,22 @@
             throw new RuntimeException(e);
         }
     }
+
+    @Override
+    public boolean onCreateOptionsMenu(Menu menu) {
+        getMenuInflater().inflate(R.menu.menu_main, menu);
+        return true;
+    }
+
+    @Override
+    public boolean onOptionsItemSelected(MenuItem item) {
+        int id = item.getItemId();
+
+        if (id == R.id.action_settings) {
+            Intent intent = new Intent(this, SettingsActivity.class);
+            startActivity(intent);
+            return true;
+        }
+        return super.onOptionsItemSelected(item);
+    }
 }
diff --git a/samples/browseable/FingerprintDialog/src/com.example.android.fingerprintdialog/SettingsActivity.java b/samples/browseable/FingerprintDialog/src/com.example.android.fingerprintdialog/SettingsActivity.java
new file mode 100644
index 0000000..08b3911
--- /dev/null
+++ b/samples/browseable/FingerprintDialog/src/com.example.android.fingerprintdialog/SettingsActivity.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2015 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.fingerprintdialog;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.preference.PreferenceFragment;
+
+public class SettingsActivity extends Activity {
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        // Display the fragment as the main content.
+        getFragmentManager().beginTransaction().replace(android.R.id.content,
+                new SettingsFragment()).commit();
+    }
+
+    /**
+     * Fragment for settings.
+     */
+    public static class SettingsFragment extends PreferenceFragment {
+
+        @Override
+        public void onCreate(Bundle savedInstanceState) {
+            super.onCreate(savedInstanceState);
+            addPreferencesFromResource(R.xml.preferences);
+        }
+    }
+}
+
+
diff --git a/samples/browseable/FloatingActionButtonBasic/res/values-v11/template-styles.xml b/samples/browseable/FloatingActionButtonBasic/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/FloatingActionButtonBasic/res/values-v11/template-styles.xml
+++ b/samples/browseable/FloatingActionButtonBasic/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/FloatingActionButtonBasic/res/values-v21/base-template-styles.xml b/samples/browseable/FloatingActionButtonBasic/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/FloatingActionButtonBasic/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/FloatingActionButtonBasic/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/FloatingActionButtonBasic/res/values/template-styles.xml b/samples/browseable/FloatingActionButtonBasic/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/FloatingActionButtonBasic/res/values/template-styles.xml
+++ b/samples/browseable/FloatingActionButtonBasic/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/Geofencing/Application/res/values-v11/template-styles.xml b/samples/browseable/Geofencing/Application/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/Geofencing/Application/res/values-v11/template-styles.xml
+++ b/samples/browseable/Geofencing/Application/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/Geofencing/Application/res/values-v21/base-template-styles.xml b/samples/browseable/Geofencing/Application/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/Geofencing/Application/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/Geofencing/Application/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/Geofencing/Application/res/values/template-styles.xml b/samples/browseable/Geofencing/Application/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/Geofencing/Application/res/values/template-styles.xml
+++ b/samples/browseable/Geofencing/Application/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/Geofencing/Wearable/src/com.example.android.wearable.geofencing/HomeListenerService.java b/samples/browseable/Geofencing/Wearable/src/com.example.android.wearable.geofencing/HomeListenerService.java
index 415fc46..251360c 100644
--- a/samples/browseable/Geofencing/Wearable/src/com.example.android.wearable.geofencing/HomeListenerService.java
+++ b/samples/browseable/Geofencing/Wearable/src/com.example.android.wearable.geofencing/HomeListenerService.java
@@ -79,7 +79,6 @@
                 postNotificationForGeofenceId(geofenceId, event.getDataItem().getUri());
             }
         }
-        dataEvents.close();
     }
 
     /**
diff --git a/samples/browseable/HdrViewfinder/AndroidManifest.xml b/samples/browseable/HdrViewfinder/AndroidManifest.xml
index 772b7df..63066f6 100644
--- a/samples/browseable/HdrViewfinder/AndroidManifest.xml
+++ b/samples/browseable/HdrViewfinder/AndroidManifest.xml
@@ -20,10 +20,6 @@
     android:versionCode="1"
     android:versionName="1.0">
 
-    <uses-sdk
-        android:minSdkVersion="21"
-        android:targetSdkVersion="21"/>
-
     <uses-feature android:name="android.hardware.camera"/>
     <uses-feature
         android:name="android.hardware.camera.front"
@@ -31,8 +27,6 @@
 
     <uses-permission android:name="android.permission.CAMERA"/>
     <uses-permission android:name="android.permission.RECORD_AUDIO"/>
-    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
-    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
 
     <application
         android:allowBackup="true"
@@ -43,7 +37,8 @@
         <activity
             android:name=".HdrViewfinderActivity"
             android:label="@string/app_name"
-            android:screenOrientation="landscape">
+            android:screenOrientation="landscape"
+                android:theme="@style/Theme.AppCompat.Light">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN"/>
                 <category android:name="android.intent.category.LAUNCHER"/>
diff --git a/samples/browseable/HdrViewfinder/res/layout/main.xml b/samples/browseable/HdrViewfinder/res/layout/main.xml
index 7507709..6fe56ef 100644
--- a/samples/browseable/HdrViewfinder/res/layout/main.xml
+++ b/samples/browseable/HdrViewfinder/res/layout/main.xml
@@ -15,13 +15,14 @@
      limitations under the License.
 -->
 <LinearLayout
-    android:id="@+id/panels"
     xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:custom="http://schemas.android.com/apk/res-auto"
     xmlns:tools="http://schemas.android.com/tools"
+    android:id="@+id/panels"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:orientation="horizontal">
+    android:orientation="horizontal"
+    tools:context="com.example.android.hdrviewfinder.HdrViewfinderActivity">
 
     <com.example.android.hdrviewfinder.FixedAspectSurfaceView
         android:id="@+id/preview"
@@ -36,7 +37,8 @@
         android:layout_width="0px"
         android:layout_height="match_parent"
         android:layout_weight="1"
-        android:orientation="vertical">
+        android:orientation="vertical"
+        android:layout_margin="5dp">
 
         <Button
             android:id="@+id/help_button"
diff --git a/samples/browseable/HdrViewfinder/res/values-v11/template-styles.xml b/samples/browseable/HdrViewfinder/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/HdrViewfinder/res/values-v11/template-styles.xml
+++ b/samples/browseable/HdrViewfinder/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/HdrViewfinder/res/values-v21/base-template-styles.xml b/samples/browseable/HdrViewfinder/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/HdrViewfinder/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/HdrViewfinder/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/HdrViewfinder/res/values/strings.xml b/samples/browseable/HdrViewfinder/res/values/strings.xml
index 21838d5..d910ab1 100644
--- a/samples/browseable/HdrViewfinder/res/values/strings.xml
+++ b/samples/browseable/HdrViewfinder/res/values/strings.xml
@@ -50,10 +50,18 @@
 
     <string name="info">Info</string>
 
+    <string name="camera_permission_rationale">This sample app requires camera access in order to
+        demo the API.</string>
     <string name="camera_no_good">No back-facing sufficiently capable camera available!</string>
     <string name="camera_disabled">Camera is disabled by device policy</string>
     <string name="camera_disconnected">Camera was disconnected before it was opened</string>
     <string name="camera_error">Camera service reported an error</string>
     <string name="camera_unknown">Unknown camera error: %s</string>
+    <string name="camera_permission_denied_explanation">You\'ve denied a permission that the app
+        needs for core functionality. If you selected &quot;don\'t ask again&quot; in the past then
+        you need to use Settings to re-enable the permission.</string>
+
+    <string name="ok">OK</string>
+    <string name="settings">Settings</string>
 
 </resources>
diff --git a/samples/browseable/HdrViewfinder/res/values/template-styles.xml b/samples/browseable/HdrViewfinder/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/HdrViewfinder/res/values/template-styles.xml
+++ b/samples/browseable/HdrViewfinder/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/HdrViewfinder/src/com.example.android.hdrviewfinder/CameraOps.java b/samples/browseable/HdrViewfinder/src/com.example.android.hdrviewfinder/CameraOps.java
index 5769760..173ef08 100644
--- a/samples/browseable/HdrViewfinder/src/com.example.android.hdrviewfinder/CameraOps.java
+++ b/samples/browseable/HdrViewfinder/src/com.example.android.hdrviewfinder/CameraOps.java
@@ -78,7 +78,7 @@
     }
 
     /**
-     * Open the first backfacing camera listed by the camera manager.
+     * Open the first back-facing camera listed by the camera manager.
      * Displays a dialog if it cannot open a camera.
      */
     public void openCamera(final String cameraId) {
diff --git a/samples/browseable/HdrViewfinder/src/com.example.android.hdrviewfinder/HdrViewfinderActivity.java b/samples/browseable/HdrViewfinder/src/com.example.android.hdrviewfinder/HdrViewfinderActivity.java
index 79f1bb6..ca49ea0 100644
--- a/samples/browseable/HdrViewfinder/src/com.example.android.hdrviewfinder/HdrViewfinderActivity.java
+++ b/samples/browseable/HdrViewfinder/src/com.example.android.hdrviewfinder/HdrViewfinderActivity.java
@@ -16,7 +16,9 @@
 
 package com.example.android.hdrviewfinder;
 
-import android.app.Activity;
+import android.Manifest;
+import android.content.Intent;
+import android.content.pm.PackageManager;
 import android.hardware.camera2.CameraAccessException;
 import android.hardware.camera2.CameraCaptureSession;
 import android.hardware.camera2.CameraCharacteristics;
@@ -26,10 +28,16 @@
 import android.hardware.camera2.CaptureResult;
 import android.hardware.camera2.TotalCaptureResult;
 import android.hardware.camera2.params.StreamConfigurationMap;
+import android.net.Uri;
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.Looper;
+import android.provider.Settings;
 import android.renderscript.RenderScript;
+import android.support.annotation.NonNull;
+import android.support.design.widget.Snackbar;
+import android.support.v4.app.ActivityCompat;
+import android.support.v7.app.AppCompatActivity;
 import android.util.Log;
 import android.util.Size;
 import android.view.GestureDetector;
@@ -76,19 +84,26 @@
  * Android {@link android.view.Surface} class, which allows for zero-copy transport of large
  * buffers between processes and subsystems.</p>
  */
-public class HdrViewfinderActivity extends Activity implements
+public class HdrViewfinderActivity extends AppCompatActivity implements
         SurfaceHolder.Callback, CameraOps.ErrorDisplayer, CameraOps.CameraReadyListener {
 
     private static final String TAG = "HdrViewfinderDemo";
 
     private static final String FRAGMENT_DIALOG = "dialog";
 
+    private static final int REQUEST_PERMISSIONS_REQUEST_CODE = 34;
+
     /**
      * View for the camera preview.
      */
     private FixedAspectSurfaceView mPreviewView;
 
     /**
+     * Root view of this activity.
+     */
+    private View rootView;
+
+    /**
      * This shows the current mode of the app.
      */
     private TextView mModeText;
@@ -132,6 +147,8 @@
         super.onCreate(savedInstanceState);
         setContentView(R.layout.main);
 
+        rootView = findViewById(R.id.panels);
+
         mPreviewView = (FixedAspectSurfaceView) findViewById(R.id.preview);
         mPreviewView.getHolder().addCallback(this);
         mPreviewView.setGestureListener(this, mViewListener);
@@ -146,23 +163,20 @@
 
         mUiHandler = new Handler(Looper.getMainLooper());
 
-        mCameraManager = (CameraManager) getSystemService(CAMERA_SERVICE);
-        mCameraOps = new CameraOps(mCameraManager,
-                /*errorDisplayer*/ this,
-                /*readyListener*/ this,
-                /*readyHandler*/ mUiHandler);
-
-        mHdrRequests.add(null);
-        mHdrRequests.add(null);
-
         mRS = RenderScript.create(this);
+
+        // When permissions are revoked the app is restarted so onCreate is sufficient to check for
+        // permissions core to the Activity's functionality.
+        if (!checkCameraPermissions()) {
+            requestCameraPermissions();
+        } else {
+            findAndOpenCamera();
+        }
     }
 
     @Override
     protected void onResume() {
         super.onResume();
-
-        findAndOpenCamera();
     }
 
     @Override
@@ -170,7 +184,10 @@
         super.onPause();
 
         // Wait until camera is closed to ensure the next application can open it
-        mCameraOps.closeCameraAndWait();
+        if (mCameraOps != null) {
+            mCameraOps.closeCameraAndWait();
+            mCameraOps = null;
+        }
     }
 
     @Override
@@ -232,7 +249,9 @@
         }
     };
 
-    // Show help dialog
+    /**
+     * Show help dialogs.
+     */
     private View.OnClickListener mHelpButtonListener = new View.OnClickListener() {
         public void onClick(View v) {
             MessageDialogFragment.newInstance(R.string.help_text)
@@ -240,54 +259,176 @@
         }
     };
 
+    /**
+     * Return the current state of the camera permissions.
+     */
+    private boolean checkCameraPermissions() {
+        int permissionState = ActivityCompat.checkSelfPermission(this, Manifest.permission.CAMERA);
+
+        // Check if the Camera permission is already available.
+        if (permissionState != PackageManager.PERMISSION_GRANTED) {
+            // Camera permission has not been granted.
+            Log.i(TAG, "CAMERA permission has NOT been granted.");
+            return false;
+        } else {
+            // Camera permissions are available.
+            Log.i(TAG, "CAMERA permission has already been granted.");
+            return true;
+        }
+    }
+
+    /**
+     * Attempt to initialize the camera.
+     */
+    private void initializeCamera() {
+        mCameraManager = (CameraManager) getSystemService(CAMERA_SERVICE);
+        if (mCameraManager != null) {
+            mCameraOps = new CameraOps(mCameraManager,
+                /*errorDisplayer*/ this,
+                /*readyListener*/ this,
+                /*readyHandler*/ mUiHandler);
+
+            mHdrRequests.add(null);
+            mHdrRequests.add(null);
+        } else {
+            Log.e(TAG, "Couldn't initialize the camera");
+        }
+    }
+
+    private void requestCameraPermissions() {
+        boolean shouldProvideRationale =
+            ActivityCompat.shouldShowRequestPermissionRationale(this,
+                    Manifest.permission.CAMERA);
+
+        // Provide an additional rationale to the user. This would happen if the user denied the
+        // request previously, but didn't check the "Don't ask again" checkbox.
+        if (shouldProvideRationale) {
+            Log.i(TAG, "Displaying camera permission rationale to provide additional context.");
+            Snackbar.make(rootView, R.string.camera_permission_rationale, Snackbar
+                    .LENGTH_INDEFINITE)
+                    .setAction(R.string.ok, new View.OnClickListener() {
+                        @Override
+                        public void onClick(View view) {
+                            // Request Camera permission
+                            ActivityCompat.requestPermissions(HdrViewfinderActivity.this,
+                                    new String[]{Manifest.permission.CAMERA},
+                                    REQUEST_PERMISSIONS_REQUEST_CODE);
+                        }
+                    })
+                    .show();
+        } else {
+            Log.i(TAG, "Requesting camera permission");
+            // Request Camera permission. It's possible this can be auto answered if device policy
+            // sets the permission in a given state or the user denied the permission
+            // previously and checked "Never ask again".
+            ActivityCompat.requestPermissions(HdrViewfinderActivity.this,
+                    new String[]{Manifest.permission.CAMERA},
+                    REQUEST_PERMISSIONS_REQUEST_CODE);
+        }
+    }
+
+    /**
+     * Callback received when a permissions request has been completed.
+     */
+    @Override
+    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
+            @NonNull int[] grantResults) {
+        Log.i(TAG, "onRequestPermissionResult");
+        if (requestCode == REQUEST_PERMISSIONS_REQUEST_CODE) {
+            if (grantResults.length <= 0) {
+                // If user interaction was interrupted, the permission request is cancelled and you
+                // receive empty arrays.
+                Log.i(TAG, "User interaction was cancelled.");
+            } else if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
+                // Permission was granted.
+                findAndOpenCamera();
+            } else {
+                // Permission denied.
+
+                // In this Activity we've chosen to notify the user that they
+                // have rejected a core permission for the app since it makes the Activity useless.
+                // We're communicating this message in a Snackbar since this is a sample app, but
+                // core permissions would typically be best requested during a welcome-screen flow.
+
+                // Additionally, it is important to remember that a permission might have been
+                // rejected without asking the user for permission (device policy or "Never ask
+                // again" prompts). Therefore, a user interface affordance is typically implemented
+                // when permissions are denied. Otherwise, your app could appear unresponsive to
+                // touches or interactions which have required permissions.
+                Snackbar.make(rootView, R.string.camera_permission_denied_explanation, Snackbar
+                        .LENGTH_INDEFINITE)
+                        .setAction(R.string.settings, new View.OnClickListener() {
+                            @Override
+                            public void onClick(View view) {
+                                // Build intent that displays the App settings screen.
+                                Intent intent = new Intent();
+                                intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
+                                Uri uri = Uri.fromParts("package", BuildConfig.APPLICATION_ID, null);
+                                intent.setData(uri);
+                                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+                                startActivity(intent);
+                            }
+                        })
+                        .show();
+            }
+        }
+    }
+
     private void findAndOpenCamera() {
+        boolean cameraPermissions = checkCameraPermissions();
+        if (cameraPermissions) {
+            String errorMessage = "Unknown error";
+            boolean foundCamera = false;
+            initializeCamera();
+            if (cameraPermissions && mCameraOps != null) {
+                try {
+                    // Find first back-facing camera that has necessary capability.
+                    String[] cameraIds = mCameraManager.getCameraIdList();
+                    for (String id : cameraIds) {
+                        CameraCharacteristics info = mCameraManager.getCameraCharacteristics(id);
+                        int facing = info.get(CameraCharacteristics.LENS_FACING);
 
-        String errorMessage = "Unknown error";
-        boolean foundCamera = false;
-        try {
-            // Find first back-facing camera that has necessary capability
-            String[] cameraIds = mCameraManager.getCameraIdList();
-            for (String id : cameraIds) {
-                CameraCharacteristics info = mCameraManager.getCameraCharacteristics(id);
-                int facing = info.get(CameraCharacteristics.LENS_FACING);
+                        int level = info.get(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL);
+                        boolean hasFullLevel
+                                = (level
+                                == CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_FULL);
 
-                int level = info.get(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL);
-                boolean hasFullLevel
-                        = (level == CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_FULL);
+                        int[] capabilities = info
+                                .get(CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES);
+                        int syncLatency = info.get(CameraCharacteristics.SYNC_MAX_LATENCY);
+                        boolean hasManualControl = hasCapability(capabilities,
+                                CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR);
+                        boolean hasEnoughCapability = hasManualControl &&
+                                syncLatency
+                                        == CameraCharacteristics.SYNC_MAX_LATENCY_PER_FRAME_CONTROL;
 
-                int[] capabilities = info.get(CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES);
-                int syncLatency = info.get(CameraCharacteristics.SYNC_MAX_LATENCY);
-                boolean hasManualControl = hasCapability(capabilities,
-                        CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR);
-                boolean hasEnoughCapability = hasManualControl &&
-                        syncLatency == CameraCharacteristics.SYNC_MAX_LATENCY_PER_FRAME_CONTROL;
-
-                // All these are guaranteed by
-                // CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_FULL, but checking for only
-                // the things we care about expands range of devices we can run on
-                // We want:
-                //  - Back-facing camera
-                //  - Manual sensor control
-                //  - Per-frame synchronization (so that exposure can be changed every frame)
-                if (facing == CameraCharacteristics.LENS_FACING_BACK &&
-                        (hasFullLevel || hasEnoughCapability)) {
-                    // Found suitable camera - get info, open, and set up outputs
-                    mCameraInfo = info;
-                    mCameraOps.openCamera(id);
-                    configureSurfaces();
-                    foundCamera = true;
-                    break;
+                        // All these are guaranteed by
+                        // CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_FULL, but checking
+                        // for only the things we care about expands range of devices we can run on.
+                        // We want:
+                        //  - Back-facing camera
+                        //  - Manual sensor control
+                        //  - Per-frame synchronization (so that exposure can be changed every frame)
+                        if (facing == CameraCharacteristics.LENS_FACING_BACK &&
+                                (hasFullLevel || hasEnoughCapability)) {
+                            // Found suitable camera - get info, open, and set up outputs
+                            mCameraInfo = info;
+                            mCameraOps.openCamera(id);
+                            configureSurfaces();
+                            foundCamera = true;
+                            break;
+                        }
+                    }
+                    if (!foundCamera) {
+                        errorMessage = getString(R.string.camera_no_good);
+                    }
+                } catch (CameraAccessException e) {
+                    errorMessage = getErrorString(e);
+                }
+                if (!foundCamera) {
+                    showErrorDialog(errorMessage);
                 }
             }
-            if (!foundCamera) {
-                errorMessage = getString(R.string.camera_no_good);
-            }
-        } catch (CameraAccessException e) {
-            errorMessage = getErrorString(e);
-        }
-
-        if (!foundCamera) {
-            showErrorDialog(errorMessage);
         }
     }
 
@@ -299,23 +440,25 @@
     }
 
     private void switchRenderMode(int direction) {
-        mRenderMode = (mRenderMode + direction) % 3;
+        if (mCameraOps != null) {
+            mRenderMode = (mRenderMode + direction) % 3;
 
-        mModeText.setText(getResources().getStringArray(R.array.mode_label_array)[mRenderMode]);
+            mModeText.setText(getResources().getStringArray(R.array.mode_label_array)[mRenderMode]);
 
-        if (mProcessor != null) {
-            mProcessor.setRenderMode(mRenderMode);
-        }
-        if (mRenderMode == ViewfinderProcessor.MODE_NORMAL) {
-            mCameraOps.setRepeatingRequest(mPreviewRequest,
-                    mCaptureCallback, mUiHandler);
-        } else {
-            setHdrBurst();
+            if (mProcessor != null) {
+                mProcessor.setRenderMode(mRenderMode);
+            }
+            if (mRenderMode == ViewfinderProcessor.MODE_NORMAL) {
+                mCameraOps.setRepeatingRequest(mPreviewRequest,
+                        mCaptureCallback, mUiHandler);
+            } else {
+                setHdrBurst();
+            }
         }
     }
 
     /**
-     * Configure the surfaceview and RS processing
+     * Configure the surfaceview and RS processing.
      */
     private void configureSurfaces() {
         // Find a good size for output - largest 16:9 aspect ratio that's less than 720p
diff --git a/samples/browseable/HorizontalPaging/res/values-v11/template-styles.xml b/samples/browseable/HorizontalPaging/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/HorizontalPaging/res/values-v11/template-styles.xml
+++ b/samples/browseable/HorizontalPaging/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/HorizontalPaging/res/values-v21/base-template-styles.xml b/samples/browseable/HorizontalPaging/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/HorizontalPaging/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/HorizontalPaging/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/HorizontalPaging/res/values/template-styles.xml b/samples/browseable/HorizontalPaging/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/HorizontalPaging/res/values/template-styles.xml
+++ b/samples/browseable/HorizontalPaging/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/ImmersiveMode/res/values-v11/template-styles.xml b/samples/browseable/ImmersiveMode/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/ImmersiveMode/res/values-v11/template-styles.xml
+++ b/samples/browseable/ImmersiveMode/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/ImmersiveMode/res/values-v21/base-template-styles.xml b/samples/browseable/ImmersiveMode/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/ImmersiveMode/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/ImmersiveMode/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/Interpolator/res/values-v11/template-styles.xml b/samples/browseable/Interpolator/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/Interpolator/res/values-v11/template-styles.xml
+++ b/samples/browseable/Interpolator/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/Interpolator/res/values-v21/base-template-styles.xml b/samples/browseable/Interpolator/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/Interpolator/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/Interpolator/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/Interpolator/res/values/template-styles.xml b/samples/browseable/Interpolator/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/Interpolator/res/values/template-styles.xml
+++ b/samples/browseable/Interpolator/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/JobScheduler/res/values-v11/template-styles.xml b/samples/browseable/JobScheduler/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/JobScheduler/res/values-v11/template-styles.xml
+++ b/samples/browseable/JobScheduler/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/JobScheduler/res/values-v21/base-template-styles.xml b/samples/browseable/JobScheduler/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/JobScheduler/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/JobScheduler/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/JobScheduler/res/values/template-styles.xml b/samples/browseable/JobScheduler/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/JobScheduler/res/values/template-styles.xml
+++ b/samples/browseable/JobScheduler/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/LNotifications/res/values-v11/template-styles.xml b/samples/browseable/LNotifications/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/LNotifications/res/values-v11/template-styles.xml
+++ b/samples/browseable/LNotifications/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/LNotifications/res/values-v21/base-template-styles.xml b/samples/browseable/LNotifications/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/LNotifications/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/LNotifications/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/LNotifications/res/values/template-styles.xml b/samples/browseable/LNotifications/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/LNotifications/res/values/template-styles.xml
+++ b/samples/browseable/LNotifications/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/MediaEffects/res/values-v11/template-styles.xml b/samples/browseable/MediaEffects/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/MediaEffects/res/values-v11/template-styles.xml
+++ b/samples/browseable/MediaEffects/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/MediaEffects/res/values-v21/base-template-styles.xml b/samples/browseable/MediaEffects/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/MediaEffects/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/MediaEffects/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/MediaEffects/res/values/template-styles.xml b/samples/browseable/MediaEffects/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/MediaEffects/res/values/template-styles.xml
+++ b/samples/browseable/MediaEffects/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/MediaRecorder/res/values-v11/template-styles.xml b/samples/browseable/MediaRecorder/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/MediaRecorder/res/values-v11/template-styles.xml
+++ b/samples/browseable/MediaRecorder/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/MediaRecorder/res/values-v21/base-template-styles.xml b/samples/browseable/MediaRecorder/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/MediaRecorder/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/MediaRecorder/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/MediaRecorder/res/values/template-styles.xml b/samples/browseable/MediaRecorder/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/MediaRecorder/res/values/template-styles.xml
+++ b/samples/browseable/MediaRecorder/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/MediaRouter/res/values-v11/template-styles.xml b/samples/browseable/MediaRouter/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/MediaRouter/res/values-v11/template-styles.xml
+++ b/samples/browseable/MediaRouter/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/MediaRouter/res/values-v21/base-template-styles.xml b/samples/browseable/MediaRouter/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/MediaRouter/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/MediaRouter/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/MediaRouter/res/values/template-styles.xml b/samples/browseable/MediaRouter/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/MediaRouter/res/values/template-styles.xml
+++ b/samples/browseable/MediaRouter/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/MessagingService/AndroidManifest.xml b/samples/browseable/MessagingService/AndroidManifest.xml
index f8a5850..955f8d4 100644
--- a/samples/browseable/MessagingService/AndroidManifest.xml
+++ b/samples/browseable/MessagingService/AndroidManifest.xml
@@ -37,13 +37,17 @@
         <service android:name=".MessagingService">
         </service>
 
-        <receiver android:name=".MessageReadReceiver">
+        <receiver
+            android:name=".MessageReadReceiver"
+            android:exported="false">
             <intent-filter>
                 <action android:name="com.example.android.messagingservice.ACTION_MESSAGE_READ"/>
             </intent-filter>
         </receiver>
 
-        <receiver android:name=".MessageReplyReceiver">
+        <receiver
+            android:name=".MessageReplyReceiver"
+            android:exported="false">
             <intent-filter>
                 <action android:name="com.example.android.messagingservice.ACTION_MESSAGE_REPLY"/>
             </intent-filter>
diff --git a/samples/browseable/MessagingService/res/layout-land/fragment_message_me.xml b/samples/browseable/MessagingService/res/layout-land/fragment_message_me.xml
index 6f4f88b..0cfd1cf 100644
--- a/samples/browseable/MessagingService/res/layout-land/fragment_message_me.xml
+++ b/samples/browseable/MessagingService/res/layout-land/fragment_message_me.xml
@@ -21,7 +21,8 @@
               android:paddingBottom="@dimen/activity_vertical_margin"
               android:paddingLeft="@dimen/activity_horizontal_margin"
               android:paddingRight="@dimen/activity_horizontal_margin"
-              android:paddingTop="@dimen/activity_vertical_margin">
+              android:paddingTop="@dimen/activity_vertical_margin"
+              android:baselineAligned="false">
     <LinearLayout
         android:layout_width="0dp"
         android:layout_height="match_parent"
diff --git a/samples/browseable/MessagingService/res/layout/fragment_message_me.xml b/samples/browseable/MessagingService/res/layout/fragment_message_me.xml
index 29a8c44..404bd4d 100644
--- a/samples/browseable/MessagingService/res/layout/fragment_message_me.xml
+++ b/samples/browseable/MessagingService/res/layout/fragment_message_me.xml
@@ -14,7 +14,6 @@
   limitations under the License.
   -->
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:orientation="vertical"
diff --git a/samples/browseable/MessagingService/res/values/strings.xml b/samples/browseable/MessagingService/res/values/strings.xml
index 001b10e..3f8390d 100644
--- a/samples/browseable/MessagingService/res/values/strings.xml
+++ b/samples/browseable/MessagingService/res/values/strings.xml
@@ -16,8 +16,6 @@
   -->
 <resources>
     <string name="app_name">Messaging Sample</string>
-    <string name="action_settings">Settings</string>
-    <string name="title">Messaging Sample</string>
     <string name="notification_reply">Reply by Voice</string>
     <string name="send_2_conversations">Send 2 conversations with 1 message</string>
     <string name="send_1_conversation">Send 1 conversation with 1 message</string>
diff --git a/samples/browseable/MessagingService/src/com.example.android.messagingservice/Conversations.java b/samples/browseable/MessagingService/src/com.example.android.messagingservice/Conversations.java
index 7425df4..88ef7aa 100644
--- a/samples/browseable/MessagingService/src/com.example.android.messagingservice/Conversations.java
+++ b/samples/browseable/MessagingService/src/com.example.android.messagingservice/Conversations.java
@@ -17,7 +17,6 @@
 package com.example.android.messagingservice;
 
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 import java.util.concurrent.ThreadLocalRandom;
diff --git a/samples/browseable/MessagingService/src/com.example.android.messagingservice/MessageLogger.java b/samples/browseable/MessagingService/src/com.example.android.messagingservice/MessageLogger.java
index d1007b5..3459178 100644
--- a/samples/browseable/MessagingService/src/com.example.android.messagingservice/MessageLogger.java
+++ b/samples/browseable/MessagingService/src/com.example.android.messagingservice/MessageLogger.java
@@ -19,6 +19,7 @@
 import android.content.Context;
 import android.content.SharedPreferences;
 
+import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 
@@ -27,13 +28,13 @@
  * and replies. Don't use this in a real world application. This logger is only
  * used for displaying the messages in the text view.
  */
-public class MessageLogger {
+class MessageLogger {
 
     private static final String PREF_MESSAGE = "MESSAGE_LOGGER";
-    private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+    private static final DateFormat DATE_FORMAT = SimpleDateFormat.getDateTimeInstance();
+    private static final String LINE_BREAKS = "\n\n";
 
     public static final String LOG_KEY = "message_data";
-    public static final String LINE_BREAKS = "\n\n";
 
     public static void logMessage(Context context, String message) {
         SharedPreferences prefs = getPrefs(context);
diff --git a/samples/browseable/MessagingService/src/com.example.android.messagingservice/MessageReadReceiver.java b/samples/browseable/MessagingService/src/com.example.android.messagingservice/MessageReadReceiver.java
index f28a3a7..63c244f 100644
--- a/samples/browseable/MessagingService/src/com.example.android.messagingservice/MessageReadReceiver.java
+++ b/samples/browseable/MessagingService/src/com.example.android.messagingservice/MessageReadReceiver.java
@@ -16,7 +16,6 @@
 
 package com.example.android.messagingservice;
 
-import android.app.NotificationManager;
 import android.content.BroadcastReceiver;
 import android.content.Context;
 import android.content.Intent;
@@ -35,8 +34,8 @@
         if (conversationId != -1) {
             Log.d(TAG, "Conversation " + conversationId + " was read");
             MessageLogger.logMessage(context, "Conversation " + conversationId + " was read.");
-            NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
-            notificationManager.cancel(conversationId);
+            NotificationManagerCompat.from(context)
+                    .cancel(conversationId);
         }
     }
 }
diff --git a/samples/browseable/MessagingService/src/com.example.android.messagingservice/MessagingFragment.java b/samples/browseable/MessagingService/src/com.example.android.messagingservice/MessagingFragment.java
index f8efcc0..703bc80 100644
--- a/samples/browseable/MessagingService/src/com.example.android.messagingservice/MessagingFragment.java
+++ b/samples/browseable/MessagingService/src/com.example.android.messagingservice/MessagingFragment.java
@@ -51,7 +51,7 @@
     private Messenger mService;
     private boolean mBound;
 
-    private ServiceConnection mConnection = new ServiceConnection() {
+    private final ServiceConnection mConnection = new ServiceConnection() {
         @Override
         public void onServiceConnected(ComponentName componentName, IBinder service) {
             mService = new Messenger(service);
@@ -67,7 +67,7 @@
         }
     };
 
-    private SharedPreferences.OnSharedPreferenceChangeListener listener =
+    private final SharedPreferences.OnSharedPreferenceChangeListener listener =
             new SharedPreferences.OnSharedPreferenceChangeListener() {
         @Override
         public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
diff --git a/samples/browseable/MessagingService/src/com.example.android.messagingservice/MessagingService.java b/samples/browseable/MessagingService/src/com.example.android.messagingservice/MessagingService.java
index f590061..73199ed 100644
--- a/samples/browseable/MessagingService/src/com.example.android.messagingservice/MessagingService.java
+++ b/samples/browseable/MessagingService/src/com.example.android.messagingservice/MessagingService.java
@@ -31,41 +31,24 @@
 import android.support.v4.app.RemoteInput;
 import android.util.Log;
 
+import java.lang.ref.WeakReference;
 import java.util.Iterator;
 
 public class MessagingService extends Service {
     private static final String TAG = MessagingService.class.getSimpleName();
-
-    public static final String READ_ACTION =
+    private static final String EOL = "\n";
+    private static final String READ_ACTION =
             "com.example.android.messagingservice.ACTION_MESSAGE_READ";
+
     public static final String REPLY_ACTION =
             "com.example.android.messagingservice.ACTION_MESSAGE_REPLY";
     public static final String CONVERSATION_ID = "conversation_id";
     public static final String EXTRA_VOICE_REPLY = "extra_voice_reply";
     public static final int MSG_SEND_NOTIFICATION = 1;
-    public static final String EOL = "\n";
 
     private NotificationManagerCompat mNotificationManager;
 
-    private final Messenger mMessenger = new Messenger(new IncomingHandler());
-
-    /**
-     * Handler of incoming messages from clients.
-     */
-    class IncomingHandler extends Handler {
-        @Override
-        public void handleMessage(Message msg) {
-            switch (msg.what) {
-                case MSG_SEND_NOTIFICATION:
-                    int howManyConversations = msg.arg1 <= 0 ? 1 : msg.arg1;
-                    int messagesPerConv = msg.arg2 <= 0 ? 1 : msg.arg2;
-                    sendNotification(howManyConversations, messagesPerConv);
-                    break;
-                default:
-                    super.handleMessage(msg);
-            }
-        }
-    }
+    private final Messenger mMessenger = new Messenger(new IncomingHandler(this));
 
     @Override
     public void onCreate() {
@@ -79,18 +62,6 @@
         return mMessenger.getBinder();
     }
 
-    @Override
-    public int onStartCommand(Intent intent, int flags, int startId) {
-        Log.d(TAG, "onStartCommand");
-        return START_STICKY;
-    }
-
-    @Override
-    public void onDestroy() {
-        super.onDestroy();
-        Log.d(TAG, "onDestroy");
-    }
-
     // Creates an intent that will be triggered when a message is marked as read.
     private Intent getMessageReadIntent(int id) {
         return new Intent()
@@ -171,4 +142,31 @@
 
         mNotificationManager.notify(conversation.getConversationId(), builder.build());
     }
+
+    /**
+     * Handler for incoming messages from clients.
+     */
+    private static class IncomingHandler extends Handler {
+        private final WeakReference<MessagingService> mReference;
+
+        IncomingHandler(MessagingService service) {
+            mReference = new WeakReference<>(service);
+        }
+
+        @Override
+        public void handleMessage(Message msg) {
+            MessagingService service = mReference.get();
+            switch (msg.what) {
+                case MSG_SEND_NOTIFICATION:
+                    int howManyConversations = msg.arg1 <= 0 ? 1 : msg.arg1;
+                    int messagesPerConversation = msg.arg2 <= 0 ? 1 : msg.arg2;
+                    if (service != null) {
+                        service.sendNotification(howManyConversations, messagesPerConversation);
+                    }
+                    break;
+                default:
+                    super.handleMessage(msg);
+            }
+        }
+    }
 }
diff --git a/samples/browseable/NavigationDrawer/res/values-v11/template-styles.xml b/samples/browseable/NavigationDrawer/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/NavigationDrawer/res/values-v11/template-styles.xml
+++ b/samples/browseable/NavigationDrawer/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/NavigationDrawer/res/values-v21/base-template-styles.xml b/samples/browseable/NavigationDrawer/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/NavigationDrawer/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/NavigationDrawer/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/NetworkConnect/res/values-v11/template-styles.xml b/samples/browseable/NetworkConnect/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/NetworkConnect/res/values-v11/template-styles.xml
+++ b/samples/browseable/NetworkConnect/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/NetworkConnect/res/values-v21/base-template-styles.xml b/samples/browseable/NetworkConnect/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/NetworkConnect/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/NetworkConnect/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/NetworkConnect/res/values/template-styles.xml b/samples/browseable/NetworkConnect/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/NetworkConnect/res/values/template-styles.xml
+++ b/samples/browseable/NetworkConnect/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/NfcProvisioning/res/values-v11/template-styles.xml b/samples/browseable/NfcProvisioning/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/NfcProvisioning/res/values-v11/template-styles.xml
+++ b/samples/browseable/NfcProvisioning/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/NfcProvisioning/res/values-v21/base-template-styles.xml b/samples/browseable/NfcProvisioning/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/NfcProvisioning/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/NfcProvisioning/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/NfcProvisioning/res/values/template-styles.xml b/samples/browseable/NfcProvisioning/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/NfcProvisioning/res/values/template-styles.xml
+++ b/samples/browseable/NfcProvisioning/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/Notifications/Application/res/values-v11/template-styles.xml b/samples/browseable/Notifications/Application/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/Notifications/Application/res/values-v11/template-styles.xml
+++ b/samples/browseable/Notifications/Application/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/Notifications/Application/res/values-v21/base-template-styles.xml b/samples/browseable/Notifications/Application/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/Notifications/Application/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/Notifications/Application/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/Notifications/Application/res/values/template-styles.xml b/samples/browseable/Notifications/Application/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/Notifications/Application/res/values/template-styles.xml
+++ b/samples/browseable/Notifications/Application/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/PdfRendererBasic/res/values-v11/template-styles.xml b/samples/browseable/PdfRendererBasic/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/PdfRendererBasic/res/values-v11/template-styles.xml
+++ b/samples/browseable/PdfRendererBasic/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/PdfRendererBasic/res/values-v21/base-template-styles.xml b/samples/browseable/PdfRendererBasic/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/PdfRendererBasic/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/PdfRendererBasic/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/PdfRendererBasic/res/values/template-styles.xml b/samples/browseable/PdfRendererBasic/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/PdfRendererBasic/res/values/template-styles.xml
+++ b/samples/browseable/PdfRendererBasic/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/PermissionRequest/res/values-v11/template-styles.xml b/samples/browseable/PermissionRequest/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/PermissionRequest/res/values-v11/template-styles.xml
+++ b/samples/browseable/PermissionRequest/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/PermissionRequest/res/values-v21/base-template-styles.xml b/samples/browseable/PermissionRequest/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/PermissionRequest/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/PermissionRequest/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/PermissionRequest/res/values/template-styles.xml b/samples/browseable/PermissionRequest/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/PermissionRequest/res/values/template-styles.xml
+++ b/samples/browseable/PermissionRequest/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/Quiz/Application/res/values-v11/template-styles.xml b/samples/browseable/Quiz/Application/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/Quiz/Application/res/values-v11/template-styles.xml
+++ b/samples/browseable/Quiz/Application/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/Quiz/Application/res/values-v21/base-template-styles.xml b/samples/browseable/Quiz/Application/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/Quiz/Application/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/Quiz/Application/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/Quiz/Application/res/values/template-styles.xml b/samples/browseable/Quiz/Application/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/Quiz/Application/res/values/template-styles.xml
+++ b/samples/browseable/Quiz/Application/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/Quiz/Application/src/com.example.android.wearable.quiz/MainActivity.java b/samples/browseable/Quiz/Application/src/com.example.android.wearable.quiz/MainActivity.java
index 1e58935..de8eb74 100644
--- a/samples/browseable/Quiz/Application/src/com.example.android.wearable.quiz/MainActivity.java
+++ b/samples/browseable/Quiz/Application/src/com.example.android.wearable.quiz/MainActivity.java
@@ -325,8 +325,8 @@
 
     @Override
     public void onDataChanged(DataEventBuffer dataEvents) {
+        // Need to freeze the dataEvents so they will exist later on the UI thread
         final List<DataEvent> events = FreezableUtils.freezeIterable(dataEvents);
-        dataEvents.close();
         runOnUiThread(new Runnable() {
             @Override
             public void run() {
@@ -445,16 +445,17 @@
                     .setResultCallback(new ResultCallback<DataItemBuffer>() {
                         @Override
                         public void onResult(DataItemBuffer result) {
-                            if (result.getStatus().isSuccess()) {
-                                List<DataItem> dataItemList = FreezableUtils.freezeIterable(result);
-                                result.close();
-                                resetDataItems(dataItemList);
-                            } else {
-                                if (Log.isLoggable(TAG, Log.DEBUG)) {
-                                    Log.d(TAG, "Reset quiz: failed to get Data Items to reset");
+                            try {
+                                if (result.getStatus().isSuccess()) {
+                                    resetDataItems(result);
+                                } else {
+                                    if (Log.isLoggable(TAG, Log.DEBUG)) {
+                                        Log.d(TAG, "Reset quiz: failed to get Data Items to reset");
+                                    }
                                 }
+                            } finally {
+                                result.release();
                             }
-                            result.close();
                         }
                     });
         } else {
@@ -467,7 +468,7 @@
         mNumSkipped = 0;
     }
 
-    private void resetDataItems(List<DataItem> dataItemList) {
+    private void resetDataItems(DataItemBuffer dataItemList) {
         if (mGoogleApiClient.isConnected()) {
             for (final DataItem dataItem : dataItemList) {
                 final Uri dataItemUri = dataItem.getUri();
@@ -521,19 +522,23 @@
                     .setResultCallback(new ResultCallback<DataItemBuffer>() {
                         @Override
                         public void onResult(DataItemBuffer result) {
-                            if (result.getStatus().isSuccess()) {
-                                List<Uri> dataItemUriList = new ArrayList<Uri>();
-                                for (final DataItem dataItem : result) {
-                                    dataItemUriList.add(dataItem.getUri());
+                            try {
+                                if (result.getStatus().isSuccess()) {
+                                    List<Uri> dataItemUriList = new ArrayList<Uri>();
+                                    for (final DataItem dataItem : result) {
+                                        dataItemUriList.add(dataItem.getUri());
+                                    }
+                                    deleteDataItems(dataItemUriList);
+                                } else {
+                                    if (Log.isLoggable(TAG, Log.DEBUG)) {
+                                        Log.d(TAG, "Clear quiz: failed to get Data Items for "
+                                                + "deletion");
+
+                                    }
                                 }
-                                result.close();
-                                deleteDataItems(dataItemUriList);
-                            } else {
-                                if (Log.isLoggable(TAG, Log.DEBUG)) {
-                                    Log.d(TAG, "Clear quiz: failed to get Data Items for deletion");
-                                }
+                            } finally {
+                                result.release();
                             }
-                            result.close();
                         }
                     });
         } else {
diff --git a/samples/browseable/Quiz/Wearable/src/com.example.android.wearable.quiz/QuizListenerService.java b/samples/browseable/Quiz/Wearable/src/com.example.android.wearable.quiz/QuizListenerService.java
index 95bedf0..5a4b906 100644
--- a/samples/browseable/Quiz/Wearable/src/com.example.android.wearable.quiz/QuizListenerService.java
+++ b/samples/browseable/Quiz/Wearable/src/com.example.android.wearable.quiz/QuizListenerService.java
@@ -40,7 +40,6 @@
 
 import com.google.android.gms.common.ConnectionResult;
 import com.google.android.gms.common.api.GoogleApiClient;
-import com.google.android.gms.common.data.FreezableUtils;
 import com.google.android.gms.wearable.DataEvent;
 import com.google.android.gms.wearable.DataEventBuffer;
 import com.google.android.gms.wearable.DataItem;
@@ -80,9 +79,6 @@
 
     @Override
     public void onDataChanged(DataEventBuffer dataEvents) {
-        final List<DataEvent> events = FreezableUtils.freezeIterable(dataEvents);
-        dataEvents.close();
-
         GoogleApiClient googleApiClient = new GoogleApiClient.Builder(this)
                 .addApi(Wearable.API)
                 .build();
@@ -94,7 +90,7 @@
             return;
         }
 
-        for (DataEvent event : events) {
+        for (DataEvent event : dataEvents) {
             if (event.getType() == DataEvent.TYPE_CHANGED) {
                 DataItem dataItem = event.getDataItem();
                 DataMap dataMap = DataMapItem.fromDataItem(dataItem).getDataMap();
diff --git a/samples/browseable/RecipeAssistant/Application/res/values-v11/template-styles.xml b/samples/browseable/RecipeAssistant/Application/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/RecipeAssistant/Application/res/values-v11/template-styles.xml
+++ b/samples/browseable/RecipeAssistant/Application/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/RecipeAssistant/Application/res/values-v21/base-template-styles.xml b/samples/browseable/RecipeAssistant/Application/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/RecipeAssistant/Application/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/RecipeAssistant/Application/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/RecipeAssistant/Application/res/values/template-styles.xml b/samples/browseable/RecipeAssistant/Application/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/RecipeAssistant/Application/res/values/template-styles.xml
+++ b/samples/browseable/RecipeAssistant/Application/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/RecyclerView/res/values-v11/template-styles.xml b/samples/browseable/RecyclerView/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/RecyclerView/res/values-v11/template-styles.xml
+++ b/samples/browseable/RecyclerView/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/RecyclerView/res/values-v21/base-template-styles.xml b/samples/browseable/RecyclerView/res/values-v21/base-template-styles.xml
index 0995e4d..8be56b8 100644
--- a/samples/browseable/RecyclerView/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/RecyclerView/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
             <item name="android:colorPrimary">@color/colorPrimary</item>
             <item name="android:colorPrimaryDark">@color/colorPrimaryDark</item>
     </style>
diff --git a/samples/browseable/RecyclerView/res/values/template-styles.xml b/samples/browseable/RecyclerView/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/RecyclerView/res/values/template-styles.xml
+++ b/samples/browseable/RecyclerView/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/RenderScriptIntrinsic/res/values-v11/template-styles.xml b/samples/browseable/RenderScriptIntrinsic/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/RenderScriptIntrinsic/res/values-v11/template-styles.xml
+++ b/samples/browseable/RenderScriptIntrinsic/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/RenderScriptIntrinsic/res/values-v21/base-template-styles.xml b/samples/browseable/RenderScriptIntrinsic/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/RenderScriptIntrinsic/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/RenderScriptIntrinsic/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/RenderScriptIntrinsic/res/values/template-styles.xml b/samples/browseable/RenderScriptIntrinsic/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/RenderScriptIntrinsic/res/values/template-styles.xml
+++ b/samples/browseable/RenderScriptIntrinsic/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/RepeatingAlarm/res/values-v11/template-styles.xml b/samples/browseable/RepeatingAlarm/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/RepeatingAlarm/res/values-v11/template-styles.xml
+++ b/samples/browseable/RepeatingAlarm/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/RepeatingAlarm/res/values-v21/base-template-styles.xml b/samples/browseable/RepeatingAlarm/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/RepeatingAlarm/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/RepeatingAlarm/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/RevealEffectBasic/res/values-v11/template-styles.xml b/samples/browseable/RevealEffectBasic/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/RevealEffectBasic/res/values-v11/template-styles.xml
+++ b/samples/browseable/RevealEffectBasic/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/RevealEffectBasic/res/values-v21/base-template-styles.xml b/samples/browseable/RevealEffectBasic/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/RevealEffectBasic/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/RevealEffectBasic/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/RevealEffectBasic/res/values/template-styles.xml b/samples/browseable/RevealEffectBasic/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/RevealEffectBasic/res/values/template-styles.xml
+++ b/samples/browseable/RevealEffectBasic/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/RuntimePermissions/_index.jd b/samples/browseable/RuntimePermissions/_index.jd
index 75c6fee..a78f3b0 100644
--- a/samples/browseable/RuntimePermissions/_index.jd
+++ b/samples/browseable/RuntimePermissions/_index.jd
@@ -5,8 +5,9 @@
 
 <p>
             
-            This sample shows runtime permissions available in the Android M and above.
-            Display the log to follow the execution.
-            If executed on an Android M device, an additional option to access contacts is shown.
+            This sample shows runtime permissions available in Android M and above.
+            Display the log on screen to follow the execution.
+            If executed on an Android M device, an additional option to access contacts is shown
+            that is declared with optional, M and above only permissions.
             
         </p>
diff --git a/samples/browseable/RuntimePermissions/res/values-v11/template-styles.xml b/samples/browseable/RuntimePermissions/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/RuntimePermissions/res/values-v11/template-styles.xml
+++ b/samples/browseable/RuntimePermissions/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/RuntimePermissions/res/values-v21/base-template-styles.xml b/samples/browseable/RuntimePermissions/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/RuntimePermissions/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/RuntimePermissions/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/RuntimePermissions/res/values/base-strings.xml b/samples/browseable/RuntimePermissions/res/values/base-strings.xml
index 58d75f9..33c535a 100644
--- a/samples/browseable/RuntimePermissions/res/values/base-strings.xml
+++ b/samples/browseable/RuntimePermissions/res/values/base-strings.xml
@@ -21,9 +21,10 @@
         <![CDATA[
         
             
-            This sample shows runtime permissions available in the Android M and above.
-            Display the log to follow the execution.
-            If executed on an Android M device, an additional option to access contacts is shown.
+            This sample shows runtime permissions available in Android M and above.
+            Display the log on screen to follow the execution.
+            If executed on an Android M device, an additional option to access contacts is shown
+            that is declared with optional, M and above only permissions.
             
         
         ]]>
diff --git a/samples/browseable/RuntimePermissions/res/values/strings.xml b/samples/browseable/RuntimePermissions/res/values/strings.xml
index 941f059..edd2c15 100644
--- a/samples/browseable/RuntimePermissions/res/values/strings.xml
+++ b/samples/browseable/RuntimePermissions/res/values/strings.xml
@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <resources>
+    <string name="ok">OK</string>
     <string name="contacts_string">Total number of contacts: %1$,d\nFirst contact:<b>%2$s</b></string>
     <string name="contacts_none">No contacts stored on device.</string>
     <string name="contacts_empty">Contacts not loaded.</string>
@@ -16,4 +17,6 @@
     <string name="permision_available_camera">Camera Permission has been granted. Preview can now be opened.</string>
     <string name="permision_available_contacts">Contacts Permissions have been granted. Contacts screen can now be opened.</string>
     <string name="permissions_not_granted">Permissions were not granted.</string>
-</resources>
\ No newline at end of file
+    <string name="permission_camera_rationale">Camera permission is needed to show the camera preview.</string>
+    <string name="permission_contacts_rationale">Contacts permissions are needed to demonstrate access.</string>
+</resources>
diff --git a/samples/browseable/RuntimePermissions/res/values/template-styles.xml b/samples/browseable/RuntimePermissions/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/RuntimePermissions/res/values/template-styles.xml
+++ b/samples/browseable/RuntimePermissions/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/RuntimePermissions/src/com.example.android.common/logger/Log.java b/samples/browseable/RuntimePermissions/src/com.example.android.common.logger/Log.java
similarity index 100%
rename from samples/browseable/RuntimePermissions/src/com.example.android.common/logger/Log.java
rename to samples/browseable/RuntimePermissions/src/com.example.android.common.logger/Log.java
diff --git a/samples/browseable/RuntimePermissions/src/com.example.android.common/logger/LogFragment.java b/samples/browseable/RuntimePermissions/src/com.example.android.common.logger/LogFragment.java
similarity index 100%
rename from samples/browseable/RuntimePermissions/src/com.example.android.common/logger/LogFragment.java
rename to samples/browseable/RuntimePermissions/src/com.example.android.common.logger/LogFragment.java
diff --git a/samples/browseable/RuntimePermissions/src/com.example.android.common/logger/LogNode.java b/samples/browseable/RuntimePermissions/src/com.example.android.common.logger/LogNode.java
similarity index 100%
rename from samples/browseable/RuntimePermissions/src/com.example.android.common/logger/LogNode.java
rename to samples/browseable/RuntimePermissions/src/com.example.android.common.logger/LogNode.java
diff --git a/samples/browseable/RuntimePermissions/src/com.example.android.common/logger/LogView.java b/samples/browseable/RuntimePermissions/src/com.example.android.common.logger/LogView.java
similarity index 100%
rename from samples/browseable/RuntimePermissions/src/com.example.android.common/logger/LogView.java
rename to samples/browseable/RuntimePermissions/src/com.example.android.common.logger/LogView.java
diff --git a/samples/browseable/RuntimePermissions/src/com.example.android.common/logger/LogWrapper.java b/samples/browseable/RuntimePermissions/src/com.example.android.common.logger/LogWrapper.java
similarity index 100%
rename from samples/browseable/RuntimePermissions/src/com.example.android.common/logger/LogWrapper.java
rename to samples/browseable/RuntimePermissions/src/com.example.android.common.logger/LogWrapper.java
diff --git a/samples/browseable/RuntimePermissions/src/com.example.android.common/logger/MessageOnlyLogFilter.java b/samples/browseable/RuntimePermissions/src/com.example.android.common.logger/MessageOnlyLogFilter.java
similarity index 100%
rename from samples/browseable/RuntimePermissions/src/com.example.android.common/logger/MessageOnlyLogFilter.java
rename to samples/browseable/RuntimePermissions/src/com.example.android.common.logger/MessageOnlyLogFilter.java
diff --git a/samples/browseable/RuntimePermissions/src/com.example.android.system.runtimepermissions/MainActivity.java b/samples/browseable/RuntimePermissions/src/com.example.android.system.runtimepermissions/MainActivity.java
index 43436aa..7abc538 100644
--- a/samples/browseable/RuntimePermissions/src/com.example.android.system.runtimepermissions/MainActivity.java
+++ b/samples/browseable/RuntimePermissions/src/com.example.android.system.runtimepermissions/MainActivity.java
@@ -16,7 +16,6 @@
 
 package com.example.android.system.runtimepermissions;
 
-import com.example.android.common.activities.SampleActivityBase;
 import com.example.android.common.logger.Log;
 import com.example.android.common.logger.LogFragment;
 import com.example.android.common.logger.LogWrapper;
@@ -26,15 +25,20 @@
 
 import android.Manifest;
 import android.app.Activity;
+import android.content.Context;
 import android.content.pm.PackageManager;
 import android.os.Bundle;
+import android.support.annotation.NonNull;
+import android.support.design.widget.Snackbar;
+import android.support.v4.app.ActivityCompat;
 import android.support.v4.app.FragmentTransaction;
 import android.view.Menu;
 import android.view.MenuItem;
 import android.view.View;
-import android.widget.Toast;
 import android.widget.ViewAnimator;
 
+import common.activities.SampleActivityBase;
+
 /**
  * Launcher Activity that demonstrates the use of runtime permissions for Android M.
  * It contains a summary sample description, sample log and a Fragment that calls callbacks on this
@@ -46,13 +50,20 @@
  * android.Manifest.permission#WRITE_CONTACTS})) are requested when the 'Show and Add Contacts'
  * button is
  * clicked to display the first contact in the contacts database and to add a dummy contact
- * directly
- * to it. First, permissions are checked if they have already been granted through {@link
- * android.app.Activity#checkSelfPermission(String)} (wrapped in {@link
- * PermissionUtil#hasSelfPermission(Activity, String)} and {@link PermissionUtil#hasSelfPermission(Activity,
- * String[])} for compatibility). If permissions have not been granted, they are requested through
- * {@link Activity#requestPermissions(String[], int)} and the return value checked in {@link
- * Activity#onRequestPermissionsResult(int, String[], int[])}.
+ * directly to it. Permissions are verified and requested through compat helpers in the support v4
+ * library, in this Activity using {@link ActivityCompat}.
+ * First, permissions are checked if they have already been granted through {@link
+ * ActivityCompat#checkSelfPermission(Context, String)}.
+ * If permissions have not been granted, they are requested through
+ * {@link ActivityCompat#requestPermissions(Activity, String[], int)} and the return value checked
+ * in
+ * a callback to the {@link android.support.v4.app.ActivityCompat.OnRequestPermissionsResultCallback}
+ * interface.
+ * <p>
+ * Before requesting permissions, {@link ActivityCompat#shouldShowRequestPermissionRationale(Activity,
+ * String)}
+ * should be called to provide the user with additional context for the use of permissions if they
+ * have been denied previously.
  * <p>
  * If this sample is executed on a device running a platform version below M, all permissions
  * declared
@@ -69,7 +80,8 @@
  * <p>
  * (This class is based on the MainActivity used in the SimpleFragment sample template.)
  */
-public class MainActivity extends SampleActivityBase {
+public class MainActivity extends SampleActivityBase
+        implements ActivityCompat.OnRequestPermissionsResultCallback {
 
     public static final String TAG = "MainActivity";
 
@@ -92,6 +104,10 @@
     // Whether the Log Fragment is currently shown.
     private boolean mLogShown;
 
+    /**
+     * Root of the layout of this Activity.
+     */
+    private View mLayout;
 
     /**
      * Called when the 'show camera' button is clicked.
@@ -101,40 +117,123 @@
         Log.i(TAG, "Show camera button pressed. Checking permission.");
         // BEGIN_INCLUDE(camera_permission)
         // Check if the Camera permission is already available.
-        if (PermissionUtil.hasSelfPermission(this, Manifest.permission.CAMERA)) {
+        if (ActivityCompat.checkSelfPermission(this, Manifest.permission.CAMERA)
+                != PackageManager.PERMISSION_GRANTED) {
+            // Camera permission has not been granted.
+
+            requestCameraPermission();
+
+        } else {
+
+            // Camera permissions is already available, show the camera preview.
             Log.i(TAG,
                     "CAMERA permission has already been granted. Displaying camera preview.");
-            // Camera permissions is already available, show the camera preview.
             showCameraPreview();
-        } else {
-            Log.i(TAG, "CAMERA permission has NOT been granted. Requesting permission.");
-            // Camera permission has not been granted. Request it.
-            requestPermissions(new String[]{Manifest.permission.CAMERA}, REQUEST_CAMERA);
         }
         // END_INCLUDE(camera_permission)
 
     }
 
     /**
+     * Requests the Camera permission.
+     * If the permission has been denied previously, a SnackBar will prompt the user to grant the
+     * permission, otherwise it is requested directly.
+     */
+    private void requestCameraPermission() {
+        Log.i(TAG, "CAMERA permission has NOT been granted. Requesting permission.");
+
+        // BEGIN_INCLUDE(camera_permission_request)
+        if (ActivityCompat.shouldShowRequestPermissionRationale(this,
+                Manifest.permission.CAMERA)) {
+            // Provide an additional rationale to the user if the permission was not granted
+            // and the user would benefit from additional context for the use of the permission.
+            // For example if the user has previously denied the permission.
+            Log.i(TAG,
+                    "Displaying camera permission rationale to provide additional context.");
+            Snackbar.make(mLayout, R.string.permission_camera_rationale,
+                    Snackbar.LENGTH_INDEFINITE)
+                    .setAction(R.string.ok, new View.OnClickListener() {
+                        @Override
+                        public void onClick(View view) {
+                            ActivityCompat.requestPermissions(MainActivity.this,
+                                    new String[]{Manifest.permission.CAMERA},
+                                    REQUEST_CAMERA);
+                        }
+                    })
+                    .show();
+        } else {
+
+            // Camera permission has not been granted yet. Request it directly.
+            ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA},
+                    REQUEST_CAMERA);
+        }
+        // END_INCLUDE(camera_permission_request)
+    }
+
+    /**
      * Called when the 'show camera' button is clicked.
      * Callback is defined in resource layout definition.
      */
     public void showContacts(View v) {
         Log.i(TAG, "Show contacts button pressed. Checking permissions.");
+
         // Verify that all required contact permissions have been granted.
-        if (PermissionUtil.hasSelfPermission(this, PERMISSIONS_CONTACT)) {
+        if (ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_CONTACTS)
+                != PackageManager.PERMISSION_GRANTED
+                || ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_CONTACTS)
+                != PackageManager.PERMISSION_GRANTED) {
+            // Contacts permissions have not been granted.
+            Log.i(TAG, "Contact permissions has NOT been granted. Requesting permissions.");
+            requestContactsPermissions();
+
+        } else {
+
+            // Contact permissions have been granted. Show the contacts fragment.
             Log.i(TAG,
                     "Contact permissions have already been granted. Displaying contact details.");
-            // Contact permissions have been granted. Show the contacts fragment.
             showContactDetails();
-        } else {
-            Log.i(TAG, "Contact permissions has NOT been granted. Requesting permission.");
-            // contact permissions has not been granted (read and write contacts). Request them.
-            requestPermissions(PERMISSIONS_CONTACT, REQUEST_CONTACTS);
         }
     }
 
     /**
+     * Requests the Contacts permissions.
+     * If the permission has been denied previously, a SnackBar will prompt the user to grant the
+     * permission, otherwise it is requested directly.
+     */
+    private void requestContactsPermissions() {
+        // BEGIN_INCLUDE(contacts_permission_request)
+        if (ActivityCompat.shouldShowRequestPermissionRationale(this,
+                Manifest.permission.READ_CONTACTS)
+                || ActivityCompat.shouldShowRequestPermissionRationale(this,
+                Manifest.permission.WRITE_CONTACTS)) {
+
+            // Provide an additional rationale to the user if the permission was not granted
+            // and the user would benefit from additional context for the use of the permission.
+            // For example, if the request has been denied previously.
+            Log.i(TAG,
+                    "Displaying contacts permission rationale to provide additional context.");
+
+            // Display a SnackBar with an explanation and a button to trigger the request.
+            Snackbar.make(mLayout, R.string.permission_contacts_rationale,
+                    Snackbar.LENGTH_INDEFINITE)
+                    .setAction(R.string.ok, new View.OnClickListener() {
+                        @Override
+                        public void onClick(View view) {
+                            ActivityCompat
+                                    .requestPermissions(MainActivity.this, PERMISSIONS_CONTACT,
+                                            REQUEST_CONTACTS);
+                        }
+                    })
+                    .show();
+        } else {
+            // Contact permissions have not been granted yet. Request them directly.
+            ActivityCompat.requestPermissions(this, PERMISSIONS_CONTACT, REQUEST_CONTACTS);
+        }
+        // END_INCLUDE(contacts_permission_request)
+    }
+
+
+    /**
      * Display the {@link CameraPreviewFragment} in the content area if the required Camera
      * permission has been granted.
      */
@@ -162,8 +261,8 @@
      * Callback received when a permissions request has been completed.
      */
     @Override
-    public void onRequestPermissionsResult(int requestCode, String[] permissions,
-            int[] grantResults) {
+    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
+            @NonNull int[] grantResults) {
 
         if (requestCode == REQUEST_CAMERA) {
             // BEGIN_INCLUDE(permission_result)
@@ -171,14 +270,15 @@
             Log.i(TAG, "Received response for Camera permission request.");
 
             // Check if the only required permission has been granted
-            if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
+            if (grantResults.length == 1 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                 // Camera permission has been granted, preview can be displayed
                 Log.i(TAG, "CAMERA permission has now been granted. Showing preview.");
-                Toast.makeText(this, R.string.permision_available_camera, Toast.LENGTH_SHORT)
-                        .show();
+                Snackbar.make(mLayout, R.string.permision_available_camera,
+                        Snackbar.LENGTH_SHORT).show();
             } else {
                 Log.i(TAG, "CAMERA permission was NOT granted.");
-                Toast.makeText(this, R.string.permissions_not_granted, Toast.LENGTH_SHORT).show();
+                Snackbar.make(mLayout, R.string.permissions_not_granted,
+                        Snackbar.LENGTH_SHORT).show();
 
             }
             // END_INCLUDE(permission_result)
@@ -190,11 +290,14 @@
             // checked.
             if (PermissionUtil.verifyPermissions(grantResults)) {
                 // All required permissions have been granted, display contacts fragment.
-                Toast.makeText(this, R.string.permision_available_contacts, Toast.LENGTH_SHORT)
+                Snackbar.make(mLayout, R.string.permision_available_contacts,
+                        Snackbar.LENGTH_SHORT)
                         .show();
             } else {
                 Log.i(TAG, "Contacts permissions were NOT granted.");
-                Toast.makeText(this, R.string.permissions_not_granted, Toast.LENGTH_SHORT).show();
+                Snackbar.make(mLayout, R.string.permissions_not_granted,
+                        Snackbar.LENGTH_SHORT)
+                        .show();
             }
 
         } else {
@@ -264,6 +367,7 @@
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_main);
+        mLayout = findViewById(R.id.sample_main_layout);
 
         if (savedInstanceState == null) {
             FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
diff --git a/samples/browseable/RuntimePermissions/src/com.example.android.system.runtimepermissions/PermissionUtil.java b/samples/browseable/RuntimePermissions/src/com.example.android.system.runtimepermissions/PermissionUtil.java
index d0742ea..b9be625 100644
--- a/samples/browseable/RuntimePermissions/src/com.example.android.system.runtimepermissions/PermissionUtil.java
+++ b/samples/browseable/RuntimePermissions/src/com.example.android.system.runtimepermissions/PermissionUtil.java
@@ -18,7 +18,6 @@
 
 import android.app.Activity;
 import android.content.pm.PackageManager;
-import android.os.Build;
 
 /**
  * Utility class that wraps access to the runtime permissions API in M and provides basic helper
@@ -33,6 +32,11 @@
      * @see Activity#onRequestPermissionsResult(int, String[], int[])
      */
     public static boolean verifyPermissions(int[] grantResults) {
+        // At least one result must be checked.
+        if(grantResults.length < 1){
+            return false;
+        }
+
         // Verify that each required permission has been granted, otherwise return false.
         for (int result : grantResults) {
             if (result != PackageManager.PERMISSION_GRANTED) {
@@ -42,43 +46,4 @@
         return true;
     }
 
-    /**
-     * Returns true if the Activity has access to all given permissions.
-     * Always returns true on platforms below M.
-     *
-     * @see Activity#checkSelfPermission(String)
-     */
-    public static boolean hasSelfPermission(Activity activity, String[] permissions) {
-        // Below Android M all permissions are granted at install time and are already available.
-        if (!isMNC()) {
-            return true;
-        }
-
-        // Verify that all required permissions have been granted
-        for (String permission : permissions) {
-            if (activity.checkSelfPermission(permission) != PackageManager.PERMISSION_GRANTED) {
-                return false;
-            }
-        }
-        return true;
-    }
-
-    /**
-     * Returns true if the Activity has access to a given permission.
-     * Always returns true on platforms below M.
-     *
-     * @see Activity#checkSelfPermission(String)
-     */
-    public static boolean hasSelfPermission(Activity activity, String permission) {
-        // Below Android M all permissions are granted at install time and are already available.
-        if (!isMNC()) {
-            return true;
-        }
-
-        return activity.checkSelfPermission(permission) == PackageManager.PERMISSION_GRANTED;
-    }
-
-    public static boolean isMNC() {
-        return Build.VERSION.SDK_INT >= Build.VERSION_CODES.M;
-    }
 }
diff --git a/samples/browseable/RuntimePermissions/src/com.example.android.system.runtimepermissions/RuntimePermissionsFragment.java b/samples/browseable/RuntimePermissions/src/com.example.android.system.runtimepermissions/RuntimePermissionsFragment.java
index b35bfeb..d38195f 100644
--- a/samples/browseable/RuntimePermissions/src/com.example.android.system.runtimepermissions/RuntimePermissionsFragment.java
+++ b/samples/browseable/RuntimePermissions/src/com.example.android.system.runtimepermissions/RuntimePermissionsFragment.java
@@ -16,6 +16,7 @@
 
 package com.example.android.system.runtimepermissions;
 
+import android.os.Build;
 import android.os.Bundle;
 import android.support.annotation.Nullable;
 import android.support.v4.app.Fragment;
@@ -32,16 +33,16 @@
         View root = inflater.inflate(R.layout.fragment_main, null);
 
         // BEGIN_INCLUDE(m_only_permission)
-        if (!PermissionUtil.isMNC()) {
+        if (Build.VERSION.SDK_INT < 23) {
             /*
-            The contacts permissions have been declared in the AndroidManifest for Android M only.
-            They are not available on older platforms, so we are hiding the button to access the
-            contacts database.
+            The contacts permissions have been declared in the AndroidManifest for Android M  and
+            above only. They are not available on older platforms, so we are hiding the button to
+            access the contacts database.
             This shows how new runtime-only permissions can be added, that do not apply to older
             platform versions. This can be useful for automated updates where additional
             permissions might prompt the user on upgrade.
              */
-            root.findViewById(R.id.button_camera).setVisibility(View.GONE);
+            root.findViewById(R.id.button_contacts).setVisibility(View.GONE);
         }
         // END_INCLUDE(m_only_permission)
 
diff --git a/samples/browseable/RuntimePermissions/src/com.example.android.system.runtimepermissions/camera/CameraPreviewFragment.java b/samples/browseable/RuntimePermissions/src/com.example.android.system.runtimepermissions/camera/CameraPreviewFragment.java
index d0938f6..871cf75 100644
--- a/samples/browseable/RuntimePermissions/src/com.example.android.system.runtimepermissions/camera/CameraPreviewFragment.java
+++ b/samples/browseable/RuntimePermissions/src/com.example.android.system.runtimepermissions/camera/CameraPreviewFragment.java
@@ -61,8 +61,13 @@
 
         // Open an instance of the first camera and retrieve its info.
         mCamera = getCameraInstance(CAMERA_ID);
-        Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
-        Camera.getCameraInfo(CAMERA_ID, cameraInfo);
+        Camera.CameraInfo cameraInfo = null;
+
+        if (mCamera != null) {
+            // Get camera info only if the camera is available
+            cameraInfo = new Camera.CameraInfo();
+            Camera.getCameraInfo(CAMERA_ID, cameraInfo);
+        }
 
         if (mCamera == null || cameraInfo == null) {
             // Camera is not available, display error message
diff --git a/samples/browseable/RuntimePermissions/src/com.example.android.common/activities/SampleActivityBase.java b/samples/browseable/RuntimePermissions/src/common.activities/SampleActivityBase.java
similarity index 90%
rename from samples/browseable/RuntimePermissions/src/com.example.android.common/activities/SampleActivityBase.java
rename to samples/browseable/RuntimePermissions/src/common.activities/SampleActivityBase.java
index 3228927..ac3928e 100644
--- a/samples/browseable/RuntimePermissions/src/com.example.android.common/activities/SampleActivityBase.java
+++ b/samples/browseable/RuntimePermissions/src/common.activities/SampleActivityBase.java
@@ -14,18 +14,19 @@
 * limitations under the License.
 */
 
-package com.example.android.common.activities;
-
-import android.os.Bundle;
-import android.support.v4.app.FragmentActivity;
+package common.activities;
 
 import com.example.android.common.logger.Log;
 import com.example.android.common.logger.LogWrapper;
 
+import android.os.Bundle;
+import android.support.v7.app.AppCompatActivity;
+
+
 /**
  * Base launcher activity, to handle most of the common plumbing for samples.
  */
-public class SampleActivityBase extends FragmentActivity {
+public class SampleActivityBase extends AppCompatActivity {
 
     public static final String TAG = "SampleActivityBase";
 
diff --git a/samples/browseable/RuntimePermissionsBasic/_index.jd b/samples/browseable/RuntimePermissionsBasic/_index.jd
index c4b5d4c..4fe6118 100644
--- a/samples/browseable/RuntimePermissionsBasic/_index.jd
+++ b/samples/browseable/RuntimePermissionsBasic/_index.jd
@@ -5,7 +5,6 @@
 
 <p>
             
-            This sample shows runtime permissions available in the Android M and above.
             This sample shows a basic implementation for requesting permissions at runtime. Click the button to request the Camera permission and open a full-screen camera preview.
 Note: The "RuntimePermissions" sample provides a more complete overview over the runtime permission features available.
             
diff --git a/samples/browseable/RuntimePermissionsBasic/res/layout/activity_main.xml b/samples/browseable/RuntimePermissionsBasic/res/layout/activity_main.xml
index c3bf99c..146b8b1 100644
--- a/samples/browseable/RuntimePermissionsBasic/res/layout/activity_main.xml
+++ b/samples/browseable/RuntimePermissionsBasic/res/layout/activity_main.xml
@@ -14,27 +14,28 @@
  limitations under the License.
 -->
 
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-              xmlns:tools="http://schemas.android.com/tools"
-              android:layout_width="match_parent"
-              android:layout_height="match_parent"
-              android:paddingLeft="@dimen/horizontal_page_margin"
-              android:paddingRight="@dimen/horizontal_page_margin"
-              android:paddingTop="@dimen/vertical_page_margin"
-              android:paddingBottom="@dimen/vertical_page_margin"
-              android:orientation="vertical"
-              tools:context=".MainActivity">
+<LinearLayout android:id="@+id/main_layout"
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical"
+    android:paddingBottom="@dimen/vertical_page_margin"
+    android:paddingLeft="@dimen/horizontal_page_margin"
+    android:paddingRight="@dimen/horizontal_page_margin"
+    android:paddingTop="@dimen/vertical_page_margin"
+    tools:context=".MainActivity">
 
     <TextView
-            android:text="@string/intro"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_marginBottom="@dimen/horizontal_page_margin"/>
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginBottom="@dimen/horizontal_page_margin"
+        android:text="@string/intro" />
 
 
     <Button
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:text="Open Camera Preview"
-            android:id="@+id/button_open_camera"/>
+        android:id="@+id/button_open_camera"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="Open Camera Preview" />
 </LinearLayout>
diff --git a/samples/browseable/RuntimePermissionsBasic/res/values-v11/template-styles.xml b/samples/browseable/RuntimePermissionsBasic/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/RuntimePermissionsBasic/res/values-v11/template-styles.xml
+++ b/samples/browseable/RuntimePermissionsBasic/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/RuntimePermissionsBasic/res/values-v21/base-template-styles.xml b/samples/browseable/RuntimePermissionsBasic/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/RuntimePermissionsBasic/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/RuntimePermissionsBasic/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/RuntimePermissionsBasic/res/values/base-strings.xml b/samples/browseable/RuntimePermissionsBasic/res/values/base-strings.xml
index 1a6b6be..46f6ed8 100644
--- a/samples/browseable/RuntimePermissionsBasic/res/values/base-strings.xml
+++ b/samples/browseable/RuntimePermissionsBasic/res/values/base-strings.xml
@@ -21,7 +21,6 @@
         <![CDATA[
         
             
-            This sample shows runtime permissions available in the Android M and above.
             This sample shows a basic implementation for requesting permissions at runtime. Click the button to request the Camera permission and open a full-screen camera preview.
 Note: The "RuntimePermissions" sample provides a more complete overview over the runtime permission features available.
             
diff --git a/samples/browseable/RuntimePermissionsBasic/res/values/template-styles.xml b/samples/browseable/RuntimePermissionsBasic/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/RuntimePermissionsBasic/res/values/template-styles.xml
+++ b/samples/browseable/RuntimePermissionsBasic/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/RuntimePermissionsBasic/src/com.example.android.basicpermissions/MainActivity.java b/samples/browseable/RuntimePermissionsBasic/src/com.example.android.basicpermissions/MainActivity.java
index 36941eb..f534d40 100644
--- a/samples/browseable/RuntimePermissionsBasic/src/com.example.android.basicpermissions/MainActivity.java
+++ b/samples/browseable/RuntimePermissionsBasic/src/com.example.android.basicpermissions/MainActivity.java
@@ -20,13 +20,15 @@
 
 import android.Manifest;
 import android.app.Activity;
+import android.content.Context;
 import android.content.Intent;
 import android.content.pm.PackageManager;
-import android.os.Build;
 import android.os.Bundle;
+import android.support.design.widget.Snackbar;
+import android.support.v4.app.ActivityCompat;
+import android.support.v7.app.AppCompatActivity;
 import android.view.View;
 import android.widget.Button;
-import android.widget.Toast;
 
 /**
  * Launcher Activity that demonstrates the use of runtime permissions for Android M.
@@ -36,22 +38,32 @@
  * the permission has been granted.
  * <p>
  * First, the status of the Camera permission is checked using {@link
- * Activity#checkSelfPermission(String)}.
+ * ActivityCompat#checkSelfPermission(Context, String)}
  * If it has not been granted ({@link PackageManager#PERMISSION_GRANTED}), it is requested by
  * calling
- * {@link Activity#requestPermissions(String[], int)}. The result of the request is returned in
- * {@link Activity#onRequestPermissionsResult(int, String[], int[])}, which starts {@link
- * CameraPreviewActivity}
- * if the permission has been granted.
+ * {@link ActivityCompat#requestPermissions(Activity, String[], int)}. The result of the request is
+ * returned to the
+ * {@link android.support.v4.app.ActivityCompat.OnRequestPermissionsResultCallback}, which starts
+ * {@link
+ * CameraPreviewActivity} if the permission has been granted.
+ * <p>
+ * Note that there is no need to check the API level, the support library
+ * already takes care of this. Similar helper methods for permissions are also available in
+ * ({@link ActivityCompat},
+ * {@link android.support.v4.content.ContextCompat} and {@link android.support.v4.app.Fragment}).
  */
-public class MainActivity extends Activity {
+public class MainActivity extends AppCompatActivity
+        implements ActivityCompat.OnRequestPermissionsResultCallback {
 
     private static final int PERMISSION_REQUEST_CAMERA = 0;
 
+    private View mLayout;
+
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_main);
+        mLayout = findViewById(R.id.main_layout);
 
         // Register a listener for the 'Show Camera Preview' button.
         Button b = (Button) findViewById(R.id.button_open_camera);
@@ -69,15 +81,16 @@
         // BEGIN_INCLUDE(onRequestPermissionsResult)
         if (requestCode == PERMISSION_REQUEST_CAMERA) {
             // Request for camera permission.
-            if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
+            if (grantResults.length == 1 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                 // Permission has been granted. Start camera preview Activity.
-                Toast.makeText(this, "Camera permission was granted. Starting preview.",
-                        Toast.LENGTH_SHORT)
+                Snackbar.make(mLayout, "Camera permission was granted. Starting preview.",
+                        Snackbar.LENGTH_SHORT)
                         .show();
                 startCamera();
             } else {
                 // Permission request was denied.
-                Toast.makeText(this, "Camera permission request was denied.", Toast.LENGTH_SHORT)
+                Snackbar.make(mLayout, "Camera permission request was denied.",
+                        Snackbar.LENGTH_SHORT)
                         .show();
             }
         }
@@ -86,44 +99,57 @@
 
     private void showCameraPreview() {
         // BEGIN_INCLUDE(startCamera)
-        if (isMNC()) {
-            // On Android M and above, need to check if permission has been granted at runtime.
-            if (checkSelfPermission(Manifest.permission.CAMERA)
-                    == PackageManager.PERMISSION_GRANTED) {
-                // Permission is available, start camera preview
-                startCamera();
-                Toast.makeText(this,
-                        "Camera permission has already been granted. Starting preview.",
-                        Toast.LENGTH_SHORT).show();
-            } else {
-                // Permission has not been granted and must be requested.
-                Toast.makeText(this,
-                        "Permission is not available. Requesting camera permission.",
-                        Toast.LENGTH_SHORT).show();
-                requestPermissions(new String[]{Manifest.permission.CAMERA},
-                        PERMISSION_REQUEST_CAMERA);
-            }
-        } else {
-            /*
-             Below Android M all permissions have already been grated at install time and do not
-             need to verified or requested.
-             If a permission has been disabled in the system settings, the API will return
-             unavailable or empty data instead. */
-            Toast.makeText(this,
-                    "Requested permissions are granted at install time below M and are always "
-                            + "available at runtime.",
-                    Toast.LENGTH_SHORT).show();
+        // Check if the Camera permission has been granted
+        if (ActivityCompat.checkSelfPermission(this, Manifest.permission.CAMERA)
+                == PackageManager.PERMISSION_GRANTED) {
+            // Permission is already available, start camera preview
+            Snackbar.make(mLayout,
+                    "Camera permission is available. Starting preview.",
+                    Snackbar.LENGTH_SHORT).show();
             startCamera();
+        } else {
+            // Permission is missing and must be requested.
+            requestCameraPermission();
         }
         // END_INCLUDE(startCamera)
     }
 
+    /**
+     * Requests the {@link android.Manifest.permission#CAMERA} permission.
+     * If an additional rationale should be displayed, the user has to launch the request from
+     * a SnackBar that includes additional information.
+     */
+    private void requestCameraPermission() {
+        // Permission has not been granted and must be requested.
+        if (ActivityCompat.shouldShowRequestPermissionRationale(this,
+                Manifest.permission.CAMERA)) {
+            // Provide an additional rationale to the user if the permission was not granted
+            // and the user would benefit from additional context for the use of the permission.
+            // Display a SnackBar with a button to request the missing permission.
+            Snackbar.make(mLayout, "Camera access is required to display the camera preview.",
+                    Snackbar.LENGTH_INDEFINITE).setAction("OK", new View.OnClickListener() {
+                @Override
+                public void onClick(View view) {
+                    // Request the permission
+                    ActivityCompat.requestPermissions(MainActivity.this,
+                            new String[]{Manifest.permission.CAMERA},
+                            PERMISSION_REQUEST_CAMERA);
+                }
+            }).show();
+
+        } else {
+            Snackbar.make(mLayout,
+                    "Permission is not available. Requesting camera permission.",
+                    Snackbar.LENGTH_SHORT).show();
+            // Request the permission. The result will be received in onRequestPermissionResult().
+            ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA},
+                    PERMISSION_REQUEST_CAMERA);
+        }
+    }
+
     private void startCamera() {
         Intent intent = new Intent(this, CameraPreviewActivity.class);
         startActivity(intent);
     }
 
-    public static boolean isMNC() {
-        return Build.VERSION.SDK_INT >= Build.VERSION_CODES.M;
-    }
 }
diff --git a/samples/browseable/ScreenCapture/res/values-v11/template-styles.xml b/samples/browseable/ScreenCapture/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/ScreenCapture/res/values-v11/template-styles.xml
+++ b/samples/browseable/ScreenCapture/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/ScreenCapture/res/values-v21/base-template-styles.xml b/samples/browseable/ScreenCapture/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/ScreenCapture/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/ScreenCapture/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/ScreenCapture/res/values/template-styles.xml b/samples/browseable/ScreenCapture/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/ScreenCapture/res/values/template-styles.xml
+++ b/samples/browseable/ScreenCapture/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/SlidingTabsBasic/res/values-v11/template-styles.xml b/samples/browseable/SlidingTabsBasic/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/SlidingTabsBasic/res/values-v11/template-styles.xml
+++ b/samples/browseable/SlidingTabsBasic/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/SlidingTabsBasic/res/values-v21/base-template-styles.xml b/samples/browseable/SlidingTabsBasic/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/SlidingTabsBasic/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/SlidingTabsBasic/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/SlidingTabsBasic/res/values/template-styles.xml b/samples/browseable/SlidingTabsBasic/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/SlidingTabsBasic/res/values/template-styles.xml
+++ b/samples/browseable/SlidingTabsBasic/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/SlidingTabsColors/res/values-v11/template-styles.xml b/samples/browseable/SlidingTabsColors/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/SlidingTabsColors/res/values-v11/template-styles.xml
+++ b/samples/browseable/SlidingTabsColors/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/SlidingTabsColors/res/values-v21/base-template-styles.xml b/samples/browseable/SlidingTabsColors/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/SlidingTabsColors/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/SlidingTabsColors/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/SlidingTabsColors/res/values/template-styles.xml b/samples/browseable/SlidingTabsColors/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/SlidingTabsColors/res/values/template-styles.xml
+++ b/samples/browseable/SlidingTabsColors/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/SpeedTracker/Application/res/values-v11/template-styles.xml b/samples/browseable/SpeedTracker/Application/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/SpeedTracker/Application/res/values-v11/template-styles.xml
+++ b/samples/browseable/SpeedTracker/Application/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/SpeedTracker/Application/res/values-v21/base-template-styles.xml b/samples/browseable/SpeedTracker/Application/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/SpeedTracker/Application/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/SpeedTracker/Application/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/SpeedTracker/Application/res/values/template-styles.xml b/samples/browseable/SpeedTracker/Application/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/SpeedTracker/Application/res/values/template-styles.xml
+++ b/samples/browseable/SpeedTracker/Application/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/StorageClient/res/values-v11/template-styles.xml b/samples/browseable/StorageClient/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/StorageClient/res/values-v11/template-styles.xml
+++ b/samples/browseable/StorageClient/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/StorageClient/res/values-v21/base-template-styles.xml b/samples/browseable/StorageClient/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/StorageClient/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/StorageClient/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/StorageProvider/_index.jd b/samples/browseable/StorageProvider/_index.jd
index 600fc61..ef6f646 100644
--- a/samples/browseable/StorageProvider/_index.jd
+++ b/samples/browseable/StorageProvider/_index.jd
@@ -1,5 +1,5 @@
 
-page.tags="MyCloud"
+page.tags="StorageProvider"
 sample.group=Content
 @jd:body
 
diff --git a/samples/browseable/StorageProvider/res/values-v11/template-styles.xml b/samples/browseable/StorageProvider/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/StorageProvider/res/values-v11/template-styles.xml
+++ b/samples/browseable/StorageProvider/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/StorageProvider/res/values-v21/base-template-styles.xml b/samples/browseable/StorageProvider/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/StorageProvider/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/StorageProvider/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/StorageProvider/res/values/base-strings.xml b/samples/browseable/StorageProvider/res/values/base-strings.xml
index 1712bef..5fd804c 100644
--- a/samples/browseable/StorageProvider/res/values/base-strings.xml
+++ b/samples/browseable/StorageProvider/res/values/base-strings.xml
@@ -16,7 +16,7 @@
 -->
 
 <resources>
-    <string name="app_name">MyCloud</string>
+    <string name="app_name">StorageProvider</string>
     <string name="intro_message">
         <![CDATA[
         
diff --git a/samples/browseable/StorageProvider/src/com.example.android.storageprovider/MainActivity.java b/samples/browseable/StorageProvider/src/com.example.android.storageprovider/MainActivity.java
index 4d41ff4..5abfa12 100644
--- a/samples/browseable/StorageProvider/src/com.example.android.storageprovider/MainActivity.java
+++ b/samples/browseable/StorageProvider/src/com.example.android.storageprovider/MainActivity.java
@@ -36,7 +36,7 @@
 
     public static final String TAG = "MainActivity";
 
-    public static final String FRAGTAG = "MyCloudFragment";
+    public static final String FRAGTAG = "StorageProviderFragment";
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
@@ -45,7 +45,7 @@
 
         if (getSupportFragmentManager().findFragmentByTag(FRAGTAG) == null ) {
             FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
-            MyCloudFragment fragment = new MyCloudFragment();
+            StorageProviderFragment fragment = new StorageProviderFragment();
             transaction.add(fragment, FRAGTAG);
             transaction.commit();
         }
diff --git a/samples/browseable/SwipeRefreshLayoutBasic/res/values-v11/template-styles.xml b/samples/browseable/SwipeRefreshLayoutBasic/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/SwipeRefreshLayoutBasic/res/values-v11/template-styles.xml
+++ b/samples/browseable/SwipeRefreshLayoutBasic/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/SwipeRefreshLayoutBasic/res/values-v21/base-template-styles.xml b/samples/browseable/SwipeRefreshLayoutBasic/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/SwipeRefreshLayoutBasic/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/SwipeRefreshLayoutBasic/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/SwipeRefreshLayoutBasic/res/values/template-styles.xml b/samples/browseable/SwipeRefreshLayoutBasic/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/SwipeRefreshLayoutBasic/res/values/template-styles.xml
+++ b/samples/browseable/SwipeRefreshLayoutBasic/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/SwipeRefreshListFragment/res/values-v11/template-styles.xml b/samples/browseable/SwipeRefreshListFragment/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/SwipeRefreshListFragment/res/values-v11/template-styles.xml
+++ b/samples/browseable/SwipeRefreshListFragment/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/SwipeRefreshListFragment/res/values-v21/base-template-styles.xml b/samples/browseable/SwipeRefreshListFragment/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/SwipeRefreshListFragment/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/SwipeRefreshListFragment/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/SwipeRefreshListFragment/res/values/template-styles.xml b/samples/browseable/SwipeRefreshListFragment/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/SwipeRefreshListFragment/res/values/template-styles.xml
+++ b/samples/browseable/SwipeRefreshListFragment/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/SwipeRefreshMultipleViews/res/values-v11/template-styles.xml b/samples/browseable/SwipeRefreshMultipleViews/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/SwipeRefreshMultipleViews/res/values-v11/template-styles.xml
+++ b/samples/browseable/SwipeRefreshMultipleViews/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/SwipeRefreshMultipleViews/res/values-v21/base-template-styles.xml b/samples/browseable/SwipeRefreshMultipleViews/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/SwipeRefreshMultipleViews/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/SwipeRefreshMultipleViews/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/SwipeRefreshMultipleViews/res/values/template-styles.xml b/samples/browseable/SwipeRefreshMultipleViews/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/SwipeRefreshMultipleViews/res/values/template-styles.xml
+++ b/samples/browseable/SwipeRefreshMultipleViews/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/SynchronizedNotifications/Application/res/values-v11/template-styles.xml b/samples/browseable/SynchronizedNotifications/Application/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/SynchronizedNotifications/Application/res/values-v11/template-styles.xml
+++ b/samples/browseable/SynchronizedNotifications/Application/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/SynchronizedNotifications/Application/res/values-v21/base-template-styles.xml b/samples/browseable/SynchronizedNotifications/Application/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/SynchronizedNotifications/Application/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/SynchronizedNotifications/Application/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/TextLinkify/res/values-v11/template-styles.xml b/samples/browseable/TextLinkify/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/TextLinkify/res/values-v11/template-styles.xml
+++ b/samples/browseable/TextLinkify/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/TextLinkify/res/values-v21/base-template-styles.xml b/samples/browseable/TextLinkify/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/TextLinkify/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/TextLinkify/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/TextLinkify/res/values/template-styles.xml b/samples/browseable/TextLinkify/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/TextLinkify/res/values/template-styles.xml
+++ b/samples/browseable/TextLinkify/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/TextSwitcher/res/values-v11/template-styles.xml b/samples/browseable/TextSwitcher/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/TextSwitcher/res/values-v11/template-styles.xml
+++ b/samples/browseable/TextSwitcher/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/TextSwitcher/res/values-v21/base-template-styles.xml b/samples/browseable/TextSwitcher/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/TextSwitcher/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/TextSwitcher/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/TextSwitcher/res/values/template-styles.xml b/samples/browseable/TextSwitcher/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/TextSwitcher/res/values/template-styles.xml
+++ b/samples/browseable/TextSwitcher/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/WatchFace/Application/AndroidManifest.xml b/samples/browseable/WatchFace/Application/AndroidManifest.xml
index 732e306..5433c94 100644
--- a/samples/browseable/WatchFace/Application/AndroidManifest.xml
+++ b/samples/browseable/WatchFace/Application/AndroidManifest.xml
@@ -56,10 +56,10 @@
         </activity>
 
         <activity
-                android:name=".TiltWatchFaceConfigActivity"
+                android:name=".OpenGLWatchFaceConfigActivity"
                 android:label="@string/app_name">
             <intent-filter>
-                <action android:name="com.example.android.wearable.watchface.CONFIG_TILT" />
+                <action android:name="com.example.android.wearable.watchface.CONFIG_OPENGL" />
                 <category android:name="com.google.android.wearable.watchface.category.COMPANION_CONFIGURATION" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
diff --git a/samples/browseable/WatchFace/Application/res/layout/activity_tilt_watch_face_config.xml b/samples/browseable/WatchFace/Application/res/layout/activity_opengl_watch_face_config.xml
similarity index 95%
rename from samples/browseable/WatchFace/Application/res/layout/activity_tilt_watch_face_config.xml
rename to samples/browseable/WatchFace/Application/res/layout/activity_opengl_watch_face_config.xml
index bda2d68..f8c172d 100644
--- a/samples/browseable/WatchFace/Application/res/layout/activity_tilt_watch_face_config.xml
+++ b/samples/browseable/WatchFace/Application/res/layout/activity_opengl_watch_face_config.xml
@@ -20,7 +20,7 @@
 
     <TextView
         android:id="@+id/label"
-        android:text="@string/tilt_config_text"
+        android:text="@string/opengl_config_text"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content" />
 
diff --git a/samples/browseable/WatchFace/Application/res/values-v11/template-styles.xml b/samples/browseable/WatchFace/Application/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/WatchFace/Application/res/values-v11/template-styles.xml
+++ b/samples/browseable/WatchFace/Application/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/WatchFace/Application/res/values-v21/base-template-styles.xml b/samples/browseable/WatchFace/Application/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/WatchFace/Application/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/WatchFace/Application/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/WatchFace/Application/res/values/base-strings.xml b/samples/browseable/WatchFace/Application/res/values/base-strings.xml
index ef8f1d3..1b346c9 100644
--- a/samples/browseable/WatchFace/Application/res/values/base-strings.xml
+++ b/samples/browseable/WatchFace/Application/res/values/base-strings.xml
@@ -23,8 +23,8 @@
             
 This sample demonstrates how to create watch faces for android wear and includes a phone app
 and a wearable app. The wearable app has a variety of watch faces including analog, digital,
-opengl, calendar, etc. It also includes a watch-side configuration example. The phone app
-includes a phone-side configuration example.
+opengl, calendar, interactive, etc. It also includes a watch-side configuration example.
+The phone app includes a phone-side configuration example.
             
         
         ]]>
diff --git a/samples/browseable/WatchFace/Application/res/values/strings.xml b/samples/browseable/WatchFace/Application/res/values/strings.xml
index aacb108..6c6834f 100644
--- a/samples/browseable/WatchFace/Application/res/values/strings.xml
+++ b/samples/browseable/WatchFace/Application/res/values/strings.xml
@@ -16,7 +16,7 @@
 <resources>
     <string name="analog_config_text">This is the config activity for the Analog and Card Bounds watch faces</string>
     <string name="digital_config_text">Digital watch face configuration</string>
-    <string name="tilt_config_text">Tilt watch face configuration</string>
+    <string name="opengl_config_text">OpenGL watch face configuration</string>
     <string name="digital_config_background">Background</string>
     <string name="digital_config_hours">Hours</string>
     <string name="digital_config_minutes">Minutes</string>
diff --git a/samples/browseable/WatchFace/Application/res/values/template-styles.xml b/samples/browseable/WatchFace/Application/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/WatchFace/Application/res/values/template-styles.xml
+++ b/samples/browseable/WatchFace/Application/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/WatchFace/Application/src/com.example.android.wearable.watchface/TiltWatchFaceConfigActivity.java b/samples/browseable/WatchFace/Application/src/com.example.android.wearable.watchface/OpenGLWatchFaceConfigActivity.java
similarity index 74%
rename from samples/browseable/WatchFace/Application/src/com.example.android.wearable.watchface/TiltWatchFaceConfigActivity.java
rename to samples/browseable/WatchFace/Application/src/com.example.android.wearable.watchface/OpenGLWatchFaceConfigActivity.java
index 303e72e..49edd96 100644
--- a/samples/browseable/WatchFace/Application/src/com.example.android.wearable.watchface/TiltWatchFaceConfigActivity.java
+++ b/samples/browseable/WatchFace/Application/src/com.example.android.wearable.watchface/OpenGLWatchFaceConfigActivity.java
@@ -22,16 +22,21 @@
 import android.support.wearable.companion.WatchFaceCompanion;
 import android.widget.TextView;
 
-public class TiltWatchFaceConfigActivity extends Activity {
+/**
+ * The phone-side config activity for {@code OpenGLWatchFaceService}. The
+ * activity ({@code OpenGLWatchFaceWearableConfigActivity}) doesn't offer any configurations, but
+ * provides a template to add your own.
+ */
+public class OpenGLWatchFaceConfigActivity extends Activity {
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
-        setContentView(R.layout.activity_tilt_watch_face_config);
+        setContentView(R.layout.activity_opengl_watch_face_config);
 
         ComponentName name =
                 getIntent().getParcelableExtra(WatchFaceCompanion.EXTRA_WATCH_FACE_COMPONENT);
-        TextView label = (TextView)findViewById(R.id.label);
+        TextView label = (TextView) findViewById(R.id.label);
         label.setText(label.getText() + " (" + name.getClassName() + ")");
     }
 }
diff --git a/samples/browseable/WatchFace/Wearable/AndroidManifest.xml b/samples/browseable/WatchFace/Wearable/AndroidManifest.xml
index 14fee36..c96d730 100644
--- a/samples/browseable/WatchFace/Wearable/AndroidManifest.xml
+++ b/samples/browseable/WatchFace/Wearable/AndroidManifest.xml
@@ -76,21 +76,21 @@
         </service>
 
         <service
-                android:name=".TiltWatchFaceService"
-                android:label="@string/tilt_name"
+                android:name=".OpenGLWatchFaceService"
+                android:label="@string/opengl_name"
                 android:permission="android.permission.BIND_WALLPAPER" >
             <meta-data
                     android:name="android.service.wallpaper"
                     android:resource="@xml/watch_face" />
             <meta-data
                     android:name="com.google.android.wearable.watchface.preview"
-                    android:resource="@drawable/preview_tilt" />
+                    android:resource="@drawable/preview_opengl" />
             <meta-data
                     android:name="com.google.android.wearable.watchface.preview_circular"
-                    android:resource="@drawable/preview_tilt_circular" />
+                    android:resource="@drawable/preview_opengl_circular" />
             <meta-data
                     android:name="com.google.android.wearable.watchface.companionConfigurationAction"
-                    android:value="com.example.android.wearable.watchface.CONFIG_TILT" />
+                    android:value="com.example.android.wearable.watchface.CONFIG_OPENGL" />
 
             <intent-filter>
                 <action android:name="android.service.wallpaper.WallpaperService" />
@@ -120,6 +120,27 @@
             </intent-filter>
         </service>
 
+
+        <service
+                android:name=".InteractiveWatchFaceService"
+                android:label="@string/interactive_name"
+                android:permission="android.permission.BIND_WALLPAPER" >
+            <meta-data
+                android:name="android.service.wallpaper"
+                android:resource="@xml/watch_face" />
+            <meta-data
+                android:name="com.google.android.wearable.watchface.preview"
+                android:resource="@drawable/preview_interactive" />
+            <meta-data
+                android:name="com.google.android.wearable.watchface.preview_circular"
+                android:resource="@drawable/preview_interactive_circular" />
+            <intent-filter>
+                <action android:name="android.service.wallpaper.WallpaperService" />
+                <category
+                    android:name="com.google.android.wearable.watchface.category.WATCH_FACE" />
+            </intent-filter>
+        </service>
+
         <service
                 android:name=".DigitalWatchFaceService"
                 android:label="@string/digital_name"
diff --git a/samples/browseable/WatchFace/Wearable/res/drawable-hdpi/bg.png b/samples/browseable/WatchFace/Wearable/res/drawable-hdpi/bg.png
index 5199af2..c83911a 100644
--- a/samples/browseable/WatchFace/Wearable/res/drawable-hdpi/bg.png
+++ b/samples/browseable/WatchFace/Wearable/res/drawable-hdpi/bg.png
Binary files differ
diff --git a/samples/browseable/WatchFace/Wearable/res/drawable-hdpi/preview_analog.png b/samples/browseable/WatchFace/Wearable/res/drawable-hdpi/preview_analog.png
index ed6960d..af43c3d 100644
--- a/samples/browseable/WatchFace/Wearable/res/drawable-hdpi/preview_analog.png
+++ b/samples/browseable/WatchFace/Wearable/res/drawable-hdpi/preview_analog.png
Binary files differ
diff --git a/samples/browseable/WatchFace/Wearable/res/drawable-hdpi/preview_analog_circular.png b/samples/browseable/WatchFace/Wearable/res/drawable-hdpi/preview_analog_circular.png
index a3affe2..cb93b4e 100644
--- a/samples/browseable/WatchFace/Wearable/res/drawable-hdpi/preview_analog_circular.png
+++ b/samples/browseable/WatchFace/Wearable/res/drawable-hdpi/preview_analog_circular.png
Binary files differ
diff --git a/samples/browseable/WatchFace/Wearable/res/drawable-hdpi/preview_interactive.png b/samples/browseable/WatchFace/Wearable/res/drawable-hdpi/preview_interactive.png
new file mode 100644
index 0000000..cbfedd0
--- /dev/null
+++ b/samples/browseable/WatchFace/Wearable/res/drawable-hdpi/preview_interactive.png
Binary files differ
diff --git a/samples/browseable/WatchFace/Wearable/res/drawable-hdpi/preview_interactive_circular.png b/samples/browseable/WatchFace/Wearable/res/drawable-hdpi/preview_interactive_circular.png
new file mode 100644
index 0000000..9e51240
--- /dev/null
+++ b/samples/browseable/WatchFace/Wearable/res/drawable-hdpi/preview_interactive_circular.png
Binary files differ
diff --git a/samples/browseable/WatchFace/Wearable/res/drawable-hdpi/preview_tilt.png b/samples/browseable/WatchFace/Wearable/res/drawable-hdpi/preview_opengl.png
similarity index 100%
rename from samples/browseable/WatchFace/Wearable/res/drawable-hdpi/preview_tilt.png
rename to samples/browseable/WatchFace/Wearable/res/drawable-hdpi/preview_opengl.png
Binary files differ
diff --git a/samples/browseable/WatchFace/Wearable/res/drawable-hdpi/preview_tilt_circular.png b/samples/browseable/WatchFace/Wearable/res/drawable-hdpi/preview_opengl_circular.png
similarity index 100%
rename from samples/browseable/WatchFace/Wearable/res/drawable-hdpi/preview_tilt_circular.png
rename to samples/browseable/WatchFace/Wearable/res/drawable-hdpi/preview_opengl_circular.png
Binary files differ
diff --git a/samples/browseable/WatchFace/Wearable/res/values/color.xml b/samples/browseable/WatchFace/Wearable/res/values/color.xml
index 0da08ed..1370192 100644
--- a/samples/browseable/WatchFace/Wearable/res/values/color.xml
+++ b/samples/browseable/WatchFace/Wearable/res/values/color.xml
@@ -14,6 +14,7 @@
  limitations under the License.
 -->
 <resources>
+    <color name="digital_date">#aaaaaa</color>
     <color name="digital_am_pm">#aaaaa0</color>
     <color name="digital_colons">#aaaaa0</color>
     <color name="config_activity_background">#ffffff</color>
diff --git a/samples/browseable/WatchFace/Wearable/res/values/dimens.xml b/samples/browseable/WatchFace/Wearable/res/values/dimens.xml
index 8f04e56..4973466 100644
--- a/samples/browseable/WatchFace/Wearable/res/values/dimens.xml
+++ b/samples/browseable/WatchFace/Wearable/res/values/dimens.xml
@@ -16,11 +16,20 @@
 <resources>
     <dimen name="digital_text_size">40dp</dimen>
     <dimen name="digital_text_size_round">45dp</dimen>
+    <dimen name="digital_date_text_size">20dp</dimen>
     <dimen name="digital_am_pm_size">25dp</dimen>
     <dimen name="digital_am_pm_size_round">30dp</dimen>
     <dimen name="digital_x_offset">15dp</dimen>
     <dimen name="digital_x_offset_round">25dp</dimen>
-    <dimen name="digital_y_offset">90dp</dimen>
+    <dimen name="digital_y_offset">80dp</dimen>
+    <dimen name="digital_line_height">25dp</dimen>
     <dimen name="digital_config_color_picker_item_margin">32dp</dimen>
     <dimen name="content_padding_start">12dp</dimen>
+    <dimen name="interactive_text_size">20dp</dimen>
+    <dimen name="interactive_text_size_round">25dp</dimen>
+    <dimen name="interactive_x_offset">15dp</dimen>
+    <dimen name="interactive_x_offset_round">25dp</dimen>
+    <dimen name="interactive_y_offset">72dp</dimen>
+    <dimen name="interactive_y_offset_round">84dp</dimen>
+    <dimen name="interactive_line_height">25dp</dimen>
 </resources>
diff --git a/samples/browseable/WatchFace/Wearable/res/values/strings.xml b/samples/browseable/WatchFace/Wearable/res/values/strings.xml
index e54591f..19bc3e7 100644
--- a/samples/browseable/WatchFace/Wearable/res/values/strings.xml
+++ b/samples/browseable/WatchFace/Wearable/res/values/strings.xml
@@ -15,7 +15,8 @@
 -->
 <resources>
     <string name="app_name">WatchFace</string>
-    <string name="tilt_name">Sample Tilt</string>
+    <string name="opengl_name">Sample OpenGL</string>
+    <string name="interactive_name">Sample Interactive</string>
     <string name="analog_name">Sample Analog</string>
     <string name="sweep_name">Sample Sweep</string>
     <string name="card_bounds_name">Sample Card Bounds</string>
diff --git a/samples/browseable/WatchFace/Wearable/src/com.example.android.wearable.watchface/AnalogWatchFaceService.java b/samples/browseable/WatchFace/Wearable/src/com.example.android.wearable.watchface/AnalogWatchFaceService.java
index 15c550f..fb86ac7 100644
--- a/samples/browseable/WatchFace/Wearable/src/com.example.android.wearable.watchface/AnalogWatchFaceService.java
+++ b/samples/browseable/WatchFace/Wearable/src/com.example.android.wearable.watchface/AnalogWatchFaceService.java
@@ -20,16 +20,18 @@
 import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
-import android.content.res.Resources;
 import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
 import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.ColorMatrix;
+import android.graphics.ColorMatrixColorFilter;
 import android.graphics.Paint;
 import android.graphics.Rect;
-import android.graphics.drawable.BitmapDrawable;
-import android.graphics.drawable.Drawable;
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.Message;
+import android.support.v7.graphics.Palette;
 import android.support.wearable.watchface.CanvasWatchFaceService;
 import android.support.wearable.watchface.WatchFaceService;
 import android.support.wearable.watchface.WatchFaceStyle;
@@ -50,7 +52,7 @@
 public class AnalogWatchFaceService extends CanvasWatchFaceService {
     private static final String TAG = "AnalogWatchFaceService";
 
-    /**
+    /*
      * Update rate in milliseconds for interactive mode. We update once a second to advance the
      * second hand.
      */
@@ -62,55 +64,73 @@
     }
 
     private class Engine extends CanvasWatchFaceService.Engine {
-        static final int MSG_UPDATE_TIME = 0;
+        private static final int MSG_UPDATE_TIME = 0;
 
-        static final float TWO_PI = (float) Math.PI * 2f;
+        private static final float HOUR_STROKE_WIDTH = 5f;
+        private static final float MINUTE_STROKE_WIDTH = 3f;
+        private static final float SECOND_TICK_STROKE_WIDTH = 2f;
 
-        Paint mHourPaint;
-        Paint mMinutePaint;
-        Paint mSecondPaint;
-        Paint mTickPaint;
-        boolean mMute;
-        Calendar mCalendar;
+        private static final float CENTER_GAP_AND_CIRCLE_RADIUS = 4f;
 
-        /** Handler to update the time once a second in interactive mode. */
-        final Handler mUpdateTimeHandler = new Handler() {
-            @Override
-            public void handleMessage(Message message) {
-                switch (message.what) {
-                    case MSG_UPDATE_TIME:
-                        if (Log.isLoggable(TAG, Log.VERBOSE)) {
-                            Log.v(TAG, "updating time");
-                        }
-                        invalidate();
-                        if (shouldTimerBeRunning()) {
-                            long timeMs = System.currentTimeMillis();
-                            long delayMs = INTERACTIVE_UPDATE_RATE_MS
-                                    - (timeMs % INTERACTIVE_UPDATE_RATE_MS);
-                            mUpdateTimeHandler.sendEmptyMessageDelayed(MSG_UPDATE_TIME, delayMs);
-                        }
-                        break;
-                }
-            }
-        };
+        private static final int SHADOW_RADIUS = 6;
 
-        final BroadcastReceiver mTimeZoneReceiver = new BroadcastReceiver() {
+        private Calendar mCalendar;
+        private boolean mRegisteredTimeZoneReceiver = false;
+        private boolean mMuteMode;
+
+        private float mCenterX;
+        private float mCenterY;
+
+        private float mSecondHandLength;
+        private float sMinuteHandLength;
+        private float sHourHandLength;
+
+        /* Colors for all hands (hour, minute, seconds, ticks) based on photo loaded. */
+        private int mWatchHandColor;
+        private int mWatchHandHightlightColor;
+        private int mWatchHandShadowColor;
+
+        private Paint mHourPaint;
+        private Paint mMinutePaint;
+        private Paint mSecondPaint;
+        private Paint mTickAndCirclePaint;
+
+        private Paint mBackgroundPaint;
+        private Bitmap mBackgroundBitmap;
+        private Bitmap mGrayBackgroundBitmap;
+
+        private boolean mAmbient;
+        private boolean mLowBitAmbient;
+        private boolean mBurnInProtection;
+
+        private Rect mPeekCardBounds = new Rect();
+
+        private final BroadcastReceiver mTimeZoneReceiver = new BroadcastReceiver() {
             @Override
             public void onReceive(Context context, Intent intent) {
                 mCalendar.setTimeZone(TimeZone.getDefault());
                 invalidate();
             }
         };
-        boolean mRegisteredTimeZoneReceiver = false;
 
-        /**
-         * Whether the display supports fewer bits for each color in ambient mode. When true, we
-         * disable anti-aliasing in ambient mode.
-         */
-        boolean mLowBitAmbient;
+        /* Handler to update the time once a second in interactive mode. */
+        private final Handler mUpdateTimeHandler = new Handler() {
+            @Override
+            public void handleMessage(Message message) {
 
-        Bitmap mBackgroundBitmap;
-        Bitmap mBackgroundScaledBitmap;
+                if (Log.isLoggable(TAG, Log.DEBUG)) {
+                    Log.d(TAG, "updating time");
+                }
+                invalidate();
+                if (shouldTimerBeRunning()) {
+                    long timeMs = System.currentTimeMillis();
+                    long delayMs = INTERACTIVE_UPDATE_RATE_MS
+                            - (timeMs % INTERACTIVE_UPDATE_RATE_MS);
+                    mUpdateTimeHandler.sendEmptyMessageDelayed(MSG_UPDATE_TIME, delayMs);
+                }
+
+            }
+        };
 
         @Override
         public void onCreate(SurfaceHolder holder) {
@@ -125,32 +145,61 @@
                     .setShowSystemUiTime(false)
                     .build());
 
-            Resources resources = AnalogWatchFaceService.this.getResources();
-            Drawable backgroundDrawable = resources.getDrawable(R.drawable.bg, null /* theme */);
-            mBackgroundBitmap = ((BitmapDrawable) backgroundDrawable).getBitmap();
+            mBackgroundPaint = new Paint();
+            mBackgroundPaint.setColor(Color.BLACK);
+            mBackgroundBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.bg);
+
+            /* Set defaults for colors */
+            mWatchHandColor = Color.WHITE;
+            mWatchHandHightlightColor = Color.RED;
+            mWatchHandShadowColor = Color.BLACK;
 
             mHourPaint = new Paint();
-            mHourPaint.setARGB(255, 200, 200, 200);
-            mHourPaint.setStrokeWidth(5.f);
+            mHourPaint.setColor(mWatchHandColor);
+            mHourPaint.setStrokeWidth(HOUR_STROKE_WIDTH);
             mHourPaint.setAntiAlias(true);
             mHourPaint.setStrokeCap(Paint.Cap.ROUND);
+            mHourPaint.setShadowLayer(SHADOW_RADIUS, 0, 0, mWatchHandShadowColor);
 
             mMinutePaint = new Paint();
-            mMinutePaint.setARGB(255, 200, 200, 200);
-            mMinutePaint.setStrokeWidth(3.f);
+            mMinutePaint.setColor(mWatchHandColor);
+            mMinutePaint.setStrokeWidth(MINUTE_STROKE_WIDTH);
             mMinutePaint.setAntiAlias(true);
             mMinutePaint.setStrokeCap(Paint.Cap.ROUND);
+            mMinutePaint.setShadowLayer(SHADOW_RADIUS, 0, 0, mWatchHandShadowColor);
 
             mSecondPaint = new Paint();
-            mSecondPaint.setARGB(255, 255, 0, 0);
-            mSecondPaint.setStrokeWidth(2.f);
+            mSecondPaint.setColor(mWatchHandHightlightColor);
+            mSecondPaint.setStrokeWidth(SECOND_TICK_STROKE_WIDTH);
             mSecondPaint.setAntiAlias(true);
             mSecondPaint.setStrokeCap(Paint.Cap.ROUND);
+            mSecondPaint.setShadowLayer(SHADOW_RADIUS, 0, 0, mWatchHandShadowColor);
 
-            mTickPaint = new Paint();
-            mTickPaint.setARGB(100, 255, 255, 255);
-            mTickPaint.setStrokeWidth(2.f);
-            mTickPaint.setAntiAlias(true);
+            mTickAndCirclePaint = new Paint();
+            mTickAndCirclePaint.setColor(mWatchHandColor);
+            mTickAndCirclePaint.setStrokeWidth(SECOND_TICK_STROKE_WIDTH);
+            mTickAndCirclePaint.setAntiAlias(true);
+            mTickAndCirclePaint.setStyle(Paint.Style.STROKE);
+            mTickAndCirclePaint.setShadowLayer(SHADOW_RADIUS, 0, 0, mWatchHandShadowColor);
+
+            /* Extract colors from background image to improve watchface style. */
+            Palette.generateAsync(
+                    mBackgroundBitmap,
+                    new Palette.PaletteAsyncListener() {
+                        @Override
+                        public void onGenerated(Palette palette) {
+                            if (palette != null) {
+                                if (Log.isLoggable(TAG, Log.DEBUG)) {
+                                    Log.d(TAG, "Palette: " + palette);
+                                }
+
+                                mWatchHandHightlightColor = palette.getVibrantColor(Color.RED);
+                                mWatchHandColor = palette.getLightVibrantColor(Color.WHITE);
+                                mWatchHandShadowColor = palette.getDarkMutedColor(Color.BLACK);
+                                updateWatchHandStyle();
+                            }
+                        }
+                    });
 
             mCalendar = Calendar.getInstance();
         }
@@ -164,18 +213,17 @@
         @Override
         public void onPropertiesChanged(Bundle properties) {
             super.onPropertiesChanged(properties);
-            mLowBitAmbient = properties.getBoolean(PROPERTY_LOW_BIT_AMBIENT, false);
             if (Log.isLoggable(TAG, Log.DEBUG)) {
                 Log.d(TAG, "onPropertiesChanged: low-bit ambient = " + mLowBitAmbient);
             }
+
+            mLowBitAmbient = properties.getBoolean(PROPERTY_LOW_BIT_AMBIENT, false);
+            mBurnInProtection = properties.getBoolean(PROPERTY_BURN_IN_PROTECTION, false);
         }
 
         @Override
         public void onTimeTick() {
             super.onTimeTick();
-            if (Log.isLoggable(TAG, Log.DEBUG)) {
-                Log.d(TAG, "onTimeTick: ambient = " + isInAmbientMode());
-            }
             invalidate();
         }
 
@@ -185,26 +233,57 @@
             if (Log.isLoggable(TAG, Log.DEBUG)) {
                 Log.d(TAG, "onAmbientModeChanged: " + inAmbientMode);
             }
-            if (mLowBitAmbient) {
-                boolean antiAlias = !inAmbientMode;
-                mHourPaint.setAntiAlias(antiAlias);
-                mMinutePaint.setAntiAlias(antiAlias);
-                mSecondPaint.setAntiAlias(antiAlias);
-                mTickPaint.setAntiAlias(antiAlias);
-            }
-            invalidate();
+            mAmbient = inAmbientMode;
 
-            // Whether the timer should be running depends on whether we're in ambient mode (as well
-            // as whether we're visible), so we may need to start or stop the timer.
+            updateWatchHandStyle();
+
+            /* Check and trigger whether or not timer should be running (only in active mode). */
             updateTimer();
         }
 
+        private void updateWatchHandStyle(){
+            if (mAmbient){
+                mHourPaint.setColor(Color.WHITE);
+                mMinutePaint.setColor(Color.WHITE);
+                mSecondPaint.setColor(Color.WHITE);
+                mTickAndCirclePaint.setColor(Color.WHITE);
+
+                mHourPaint.setAntiAlias(false);
+                mMinutePaint.setAntiAlias(false);
+                mSecondPaint.setAntiAlias(false);
+                mTickAndCirclePaint.setAntiAlias(false);
+
+                mHourPaint.clearShadowLayer();
+                mMinutePaint.clearShadowLayer();
+                mSecondPaint.clearShadowLayer();
+                mTickAndCirclePaint.clearShadowLayer();
+
+            } else {
+                mHourPaint.setColor(mWatchHandColor);
+                mMinutePaint.setColor(mWatchHandColor);
+                mSecondPaint.setColor(mWatchHandHightlightColor);
+                mTickAndCirclePaint.setColor(mWatchHandColor);
+
+                mHourPaint.setAntiAlias(true);
+                mMinutePaint.setAntiAlias(true);
+                mSecondPaint.setAntiAlias(true);
+                mTickAndCirclePaint.setAntiAlias(true);
+
+                mHourPaint.setShadowLayer(SHADOW_RADIUS, 0, 0, mWatchHandShadowColor);
+                mMinutePaint.setShadowLayer(SHADOW_RADIUS, 0, 0, mWatchHandShadowColor);
+                mSecondPaint.setShadowLayer(SHADOW_RADIUS, 0, 0, mWatchHandShadowColor);
+                mTickAndCirclePaint.setShadowLayer(SHADOW_RADIUS, 0, 0, mWatchHandShadowColor);
+            }
+        }
+
         @Override
         public void onInterruptionFilterChanged(int interruptionFilter) {
             super.onInterruptionFilterChanged(interruptionFilter);
             boolean inMuteMode = (interruptionFilter == WatchFaceService.INTERRUPTION_FILTER_NONE);
-            if (mMute != inMuteMode) {
-                mMute = inMuteMode;
+
+            /* Dim display in mute mode. */
+            if (mMuteMode != inMuteMode) {
+                mMuteMode = inMuteMode;
                 mHourPaint.setAlpha(inMuteMode ? 100 : 255);
                 mMinutePaint.setAlpha(inMuteMode ? 100 : 255);
                 mSecondPaint.setAlpha(inMuteMode ? 80 : 255);
@@ -213,88 +292,180 @@
         }
 
         @Override
-        public void onDraw(Canvas canvas, Rect bounds) {
-            mCalendar.setTimeInMillis(System.currentTimeMillis());
+        public void onSurfaceChanged(SurfaceHolder holder, int format, int width, int height) {
+            super.onSurfaceChanged(holder, format, width, height);
 
-            int width = bounds.width();
-            int height = bounds.height();
+            /*
+             * Find the coordinates of the center point on the screen, and ignore the window
+             * insets, so that, on round watches with a "chin", the watch face is centered on the
+             * entire screen, not just the usable portion.
+             */
+            mCenterX = width / 2f;
+            mCenterY = height / 2f;
 
-            // Draw the background, scaled to fit.
-            if (mBackgroundScaledBitmap == null
-                    || mBackgroundScaledBitmap.getWidth() != width
-                    || mBackgroundScaledBitmap.getHeight() != height) {
-                mBackgroundScaledBitmap = Bitmap.createScaledBitmap(mBackgroundBitmap,
-                        width, height, true /* filter */);
+            /*
+             * Calculate lengths of different hands based on watch screen size.
+             */
+            mSecondHandLength = (float) (mCenterX * 0.875);
+            sMinuteHandLength = (float) (mCenterX * 0.75);
+            sHourHandLength = (float) (mCenterX * 0.5);
+
+
+            /* Scale loaded background image (more efficient) if surface dimensions change. */
+            float scale = ((float) width) / (float) mBackgroundBitmap.getWidth();
+
+            mBackgroundBitmap = Bitmap.createScaledBitmap(mBackgroundBitmap,
+                    (int) (mBackgroundBitmap.getWidth() * scale),
+                    (int) (mBackgroundBitmap.getHeight() * scale), true);
+
+            /*
+             * Create a gray version of the image only if it will look nice on the device in
+             * ambient mode. That means we don't want devices that support burn-in
+             * protection (slight movements in pixels, not great for images going all the way to
+             * edges) and low ambient mode (degrades image quality).
+             *
+             * Also, if your watch face will know about all images ahead of time (users aren't
+             * selecting their own photos for the watch face), it will be more
+             * efficient to create a black/white version (png, etc.) and load that when you need it.
+             */
+            if (!mBurnInProtection && !mLowBitAmbient) {
+                initGrayBackgroundBitmap();
             }
-            canvas.drawBitmap(mBackgroundScaledBitmap, 0, 0, null);
+        }
 
-            // Find the center. Ignore the window insets so that, on round watches with a
-            // "chin", the watch face is centered on the entire screen, not just the usable
-            // portion.
-            float centerX = width / 2f;
-            float centerY = height / 2f;
+        private void initGrayBackgroundBitmap() {
+            mGrayBackgroundBitmap = Bitmap.createBitmap(
+                    mBackgroundBitmap.getWidth(),
+                    mBackgroundBitmap.getHeight(),
+                    Bitmap.Config.ARGB_8888);
+            Canvas canvas = new Canvas(mGrayBackgroundBitmap);
+            Paint grayPaint = new Paint();
+            ColorMatrix colorMatrix = new ColorMatrix();
+            colorMatrix.setSaturation(0);
+            ColorMatrixColorFilter filter = new ColorMatrixColorFilter(colorMatrix);
+            grayPaint.setColorFilter(filter);
+            canvas.drawBitmap(mBackgroundBitmap, 0, 0, grayPaint);
+        }
 
-            // Draw the ticks.
-            float innerTickRadius = centerX - 10;
-            float outerTickRadius = centerX;
+        @Override
+        public void onDraw(Canvas canvas, Rect bounds) {
+            if (Log.isLoggable(TAG, Log.VERBOSE)) {
+                Log.v(TAG, "onDraw");
+            }
+            long now = System.currentTimeMillis();
+            mCalendar.setTimeInMillis(now);
+
+            if (mAmbient && (mLowBitAmbient || mBurnInProtection)) {
+                canvas.drawColor(Color.BLACK);
+            } else if (mAmbient) {
+                canvas.drawBitmap(mGrayBackgroundBitmap, 0, 0, mBackgroundPaint);
+            } else {
+                canvas.drawBitmap(mBackgroundBitmap, 0, 0, mBackgroundPaint);
+            }
+
+            /*
+             * Draw ticks. Usually you will want to bake this directly into the photo, but in
+             * cases where you want to allow users to select their own photos, this dynamically
+             * creates them on top of the photo.
+             */
+            float innerTickRadius = mCenterX - 10;
+            float outerTickRadius = mCenterX;
             for (int tickIndex = 0; tickIndex < 12; tickIndex++) {
-                float tickRot = tickIndex * TWO_PI / 12;
+                float tickRot = (float) (tickIndex * Math.PI * 2 / 12);
                 float innerX = (float) Math.sin(tickRot) * innerTickRadius;
                 float innerY = (float) -Math.cos(tickRot) * innerTickRadius;
                 float outerX = (float) Math.sin(tickRot) * outerTickRadius;
                 float outerY = (float) -Math.cos(tickRot) * outerTickRadius;
-                canvas.drawLine(centerX + innerX, centerY + innerY,
-                        centerX + outerX, centerY + outerY, mTickPaint);
+                canvas.drawLine(mCenterX + innerX, mCenterY + innerY,
+                        mCenterX + outerX, mCenterY + outerY, mTickAndCirclePaint);
             }
 
-            float seconds =
-                    mCalendar.get(Calendar.SECOND) + mCalendar.get(Calendar.MILLISECOND) / 1000f;
-            float secRot = seconds / 60f * TWO_PI;
-            float minutes = mCalendar.get(Calendar.MINUTE) + seconds / 60f;
-            float minRot = minutes / 60f * TWO_PI;
-            float hours = mCalendar.get(Calendar.HOUR) + minutes / 60f;
-            float hrRot = hours / 12f * TWO_PI;
+            /*
+             * These calculations reflect the rotation in degrees per unit of time, e.g.,
+             * 360 / 60 = 6 and 360 / 12 = 30.
+             */
+            final float seconds =
+                    (mCalendar.get(Calendar.SECOND) + mCalendar.get(Calendar.MILLISECOND) / 1000f);
+            final float secondsRotation = seconds * 6f;
 
-            float secLength = centerX - 20;
-            float minLength = centerX - 40;
-            float hrLength = centerX - 80;
+            final float minutesRotation = mCalendar.get(Calendar.MINUTE) * 6f;
 
-            if (!isInAmbientMode()) {
-                float secX = (float) Math.sin(secRot) * secLength;
-                float secY = (float) -Math.cos(secRot) * secLength;
-                canvas.drawLine(centerX, centerY, centerX + secX, centerY + secY, mSecondPaint);
+            final float hourHandOffset = mCalendar.get(Calendar.MINUTE) / 2f;
+            final float hoursRotation = (mCalendar.get(Calendar.HOUR) * 30) + hourHandOffset;
+
+            /*
+             * Save the canvas state before we can begin to rotate it.
+             */
+            canvas.save();
+
+            canvas.rotate(hoursRotation, mCenterX, mCenterY);
+            canvas.drawLine(
+                    mCenterX,
+                    mCenterY - CENTER_GAP_AND_CIRCLE_RADIUS,
+                    mCenterX,
+                    mCenterY - sHourHandLength,
+                    mHourPaint);
+
+            canvas.rotate(minutesRotation - hoursRotation, mCenterX, mCenterY);
+            canvas.drawLine(
+                    mCenterX,
+                    mCenterY - CENTER_GAP_AND_CIRCLE_RADIUS,
+                    mCenterX,
+                    mCenterY - sMinuteHandLength,
+                    mMinutePaint);
+
+            /*
+             * Ensure the "seconds" hand is drawn only when we are in interactive mode.
+             * Otherwise, we only update the watch face once a minute.
+             */
+            if (!mAmbient) {
+                canvas.rotate(secondsRotation - minutesRotation, mCenterX, mCenterY);
+                canvas.drawLine(
+                        mCenterX,
+                        mCenterY - CENTER_GAP_AND_CIRCLE_RADIUS,
+                        mCenterX,
+                        mCenterY - mSecondHandLength,
+                        mSecondPaint);
+
             }
+            canvas.drawCircle(
+                    mCenterX,
+                    mCenterY,
+                    CENTER_GAP_AND_CIRCLE_RADIUS,
+                    mTickAndCirclePaint);
 
-            float minX = (float) Math.sin(minRot) * minLength;
-            float minY = (float) -Math.cos(minRot) * minLength;
-            canvas.drawLine(centerX, centerY, centerX + minX, centerY + minY, mMinutePaint);
+            /* Restore the canvas' original orientation. */
+            canvas.restore();
 
-            float hrX = (float) Math.sin(hrRot) * hrLength;
-            float hrY = (float) -Math.cos(hrRot) * hrLength;
-            canvas.drawLine(centerX, centerY, centerX + hrX, centerY + hrY, mHourPaint);
+            /* Draw rectangle behind peek card in ambient mode to improve readability. */
+            if (mAmbient) {
+                canvas.drawRect(mPeekCardBounds, mBackgroundPaint);
+            }
         }
 
         @Override
         public void onVisibilityChanged(boolean visible) {
             super.onVisibilityChanged(visible);
-            if (Log.isLoggable(TAG, Log.DEBUG)) {
-                Log.d(TAG, "onVisibilityChanged: " + visible);
-            }
 
             if (visible) {
                 registerReceiver();
-
-                // Update time zone in case it changed while we weren't visible.
+                /* Update time zone in case it changed while we weren't visible. */
                 mCalendar.setTimeZone(TimeZone.getDefault());
+                invalidate();
             } else {
                 unregisterReceiver();
             }
 
-            // Whether the timer should be running depends on whether we're visible (as well as
-            // whether we're in ambient mode), so we may need to start or stop the timer.
+            /* Check and trigger whether or not timer should be running (only in active mode). */
             updateTimer();
         }
 
+        @Override
+        public void onPeekCardPositionUpdate(Rect rect) {
+            super.onPeekCardPositionUpdate(rect);
+            mPeekCardBounds.set(rect);
+        }
+
         private void registerReceiver() {
             if (mRegisteredTimeZoneReceiver) {
                 return;
@@ -313,8 +484,7 @@
         }
 
         /**
-         * Starts the {@link #mUpdateTimeHandler} timer if it should be running and isn't currently
-         * or stops it if it shouldn't be running but currently is.
+         * Starts/stops the {@link #mUpdateTimeHandler} timer based on the state of the watch face.
          */
         private void updateTimer() {
             if (Log.isLoggable(TAG, Log.DEBUG)) {
@@ -327,12 +497,11 @@
         }
 
         /**
-         * Returns whether the {@link #mUpdateTimeHandler} timer should be running. The timer should
-         * only run when we're visible and in interactive mode.
+         * Returns whether the {@link #mUpdateTimeHandler} timer should be running. The timer
+         * should only run in active mode.
          */
         private boolean shouldTimerBeRunning() {
-            return isVisible() && !isInAmbientMode();
+            return isVisible() && !mAmbient;
         }
-
     }
 }
diff --git a/samples/browseable/WatchFace/Wearable/src/com.example.android.wearable.watchface/DigitalWatchFaceService.java b/samples/browseable/WatchFace/Wearable/src/com.example.android.wearable.watchface/DigitalWatchFaceService.java
index 0bc420d..0a9eff2 100644
--- a/samples/browseable/WatchFace/Wearable/src/com.example.android.wearable.watchface/DigitalWatchFaceService.java
+++ b/samples/browseable/WatchFace/Wearable/src/com.example.android.wearable.watchface/DigitalWatchFaceService.java
@@ -46,7 +46,10 @@
 import com.google.android.gms.wearable.DataMapItem;
 import com.google.android.gms.wearable.Wearable;
 
+import java.text.SimpleDateFormat;
 import java.util.Calendar;
+import java.util.Date;
+import java.util.Locale;
 import java.util.TimeZone;
 import java.util.concurrent.TimeUnit;
 
@@ -123,16 +126,26 @@
                 .addApi(Wearable.API)
                 .build();
 
-        final BroadcastReceiver mTimeZoneReceiver = new BroadcastReceiver() {
+        /**
+         * Handles time zone and locale changes.
+         */
+        final BroadcastReceiver mReceiver = new BroadcastReceiver() {
             @Override
             public void onReceive(Context context, Intent intent) {
                 mCalendar.setTimeZone(TimeZone.getDefault());
+                initFormats();
                 invalidate();
             }
         };
-        boolean mRegisteredTimeZoneReceiver = false;
+
+        /**
+         * Unregistering an unregistered receiver throws an exception. Keep track of the
+         * registration state to prevent that.
+         */
+        boolean mRegisteredReceiver = false;
 
         Paint mBackgroundPaint;
+        Paint mDatePaint;
         Paint mHourPaint;
         Paint mMinutePaint;
         Paint mSecondPaint;
@@ -140,10 +153,16 @@
         Paint mColonPaint;
         float mColonWidth;
         boolean mMute;
+
         Calendar mCalendar;
+        Date mDate;
+        SimpleDateFormat mDayOfWeekFormat;
+        java.text.DateFormat mDateFormat;
+
         boolean mShouldDrawColons;
         float mXOffset;
         float mYOffset;
+        float mLineHeight;
         String mAmString;
         String mPmString;
         int mInteractiveBackgroundColor =
@@ -175,11 +194,13 @@
                     .build());
             Resources resources = DigitalWatchFaceService.this.getResources();
             mYOffset = resources.getDimension(R.dimen.digital_y_offset);
+            mLineHeight = resources.getDimension(R.dimen.digital_line_height);
             mAmString = resources.getString(R.string.digital_am);
             mPmString = resources.getString(R.string.digital_pm);
 
             mBackgroundPaint = new Paint();
             mBackgroundPaint.setColor(mInteractiveBackgroundColor);
+            mDatePaint = createTextPaint(resources.getColor(R.color.digital_date));
             mHourPaint = createTextPaint(mInteractiveHourDigitsColor, BOLD_TYPEFACE);
             mMinutePaint = createTextPaint(mInteractiveMinuteDigitsColor);
             mSecondPaint = createTextPaint(mInteractiveSecondDigitsColor);
@@ -187,6 +208,8 @@
             mColonPaint = createTextPaint(resources.getColor(R.color.digital_colons));
 
             mCalendar = Calendar.getInstance();
+            mDate = new Date();
+            initFormats();
         }
 
         @Override
@@ -219,8 +242,9 @@
 
                 registerReceiver();
 
-                // Update time zone in case it changed while we weren't visible.
+                // Update time zone and date formats, in case they changed while we weren't visible.
                 mCalendar.setTimeZone(TimeZone.getDefault());
+                initFormats();
             } else {
                 unregisterReceiver();
 
@@ -235,21 +259,29 @@
             updateTimer();
         }
 
+        private void initFormats() {
+            mDayOfWeekFormat = new SimpleDateFormat("EEEE", Locale.getDefault());
+            mDayOfWeekFormat.setCalendar(mCalendar);
+            mDateFormat = DateFormat.getDateFormat(DigitalWatchFaceService.this);
+            mDateFormat.setCalendar(mCalendar);
+        }
+
         private void registerReceiver() {
-            if (mRegisteredTimeZoneReceiver) {
+            if (mRegisteredReceiver) {
                 return;
             }
-            mRegisteredTimeZoneReceiver = true;
+            mRegisteredReceiver = true;
             IntentFilter filter = new IntentFilter(Intent.ACTION_TIMEZONE_CHANGED);
-            DigitalWatchFaceService.this.registerReceiver(mTimeZoneReceiver, filter);
+            filter.addAction(Intent.ACTION_LOCALE_CHANGED);
+            DigitalWatchFaceService.this.registerReceiver(mReceiver, filter);
         }
 
         private void unregisterReceiver() {
-            if (!mRegisteredTimeZoneReceiver) {
+            if (!mRegisteredReceiver) {
                 return;
             }
-            mRegisteredTimeZoneReceiver = false;
-            DigitalWatchFaceService.this.unregisterReceiver(mTimeZoneReceiver);
+            mRegisteredReceiver = false;
+            DigitalWatchFaceService.this.unregisterReceiver(mReceiver);
         }
 
         @Override
@@ -269,6 +301,7 @@
             float amPmSize = resources.getDimension(isRound
                     ? R.dimen.digital_am_pm_size_round : R.dimen.digital_am_pm_size);
 
+            mDatePaint.setTextSize(resources.getDimension(R.dimen.digital_date_text_size));
             mHourPaint.setTextSize(textSize);
             mMinutePaint.setTextSize(textSize);
             mSecondPaint.setTextSize(textSize);
@@ -321,6 +354,7 @@
 
             if (mLowBitAmbient) {
                 boolean antiAlias = !inAmbientMode;
+                mDatePaint.setAntiAlias(antiAlias);
                 mHourPaint.setAntiAlias(antiAlias);
                 mMinutePaint.setAntiAlias(antiAlias);
                 mSecondPaint.setAntiAlias(antiAlias);
@@ -335,7 +369,7 @@
         }
 
         private void adjustPaintColorToCurrentMode(Paint paint, int interactiveColor,
-                int ambientColor) {
+                                                   int ambientColor) {
             paint.setColor(isInAmbientMode() ? ambientColor : interactiveColor);
         }
 
@@ -353,6 +387,7 @@
             if (mMute != inMuteMode) {
                 mMute = inMuteMode;
                 int alpha = inMuteMode ? MUTE_ALPHA : NORMAL_ALPHA;
+                mDatePaint.setAlpha(alpha);
                 mHourPaint.setAlpha(alpha);
                 mMinutePaint.setAlpha(alpha);
                 mColonPaint.setAlpha(alpha);
@@ -409,7 +444,9 @@
 
         @Override
         public void onDraw(Canvas canvas, Rect bounds) {
-            mCalendar.setTimeInMillis(System.currentTimeMillis());
+            long now = System.currentTimeMillis();
+            mCalendar.setTimeInMillis(now);
+            mDate.setTime(now);
             boolean is24Hour = DateFormat.is24HourFormat(DigitalWatchFaceService.this);
 
             // Show colons for the first half of each second so the colons blink on when the time
@@ -430,9 +467,6 @@
                     hour = 12;
                 }
                 hourString = String.valueOf(hour);
-                if (hour < 10) {
-                    x += mHourPaint.measureText("0");
-                }
             }
             canvas.drawText(hourString, x, mYOffset, mHourPaint);
             x += mHourPaint.measureText(hourString);
@@ -463,6 +497,19 @@
                 canvas.drawText(getAmPmString(
                         mCalendar.get(Calendar.AM_PM)), x, mYOffset, mAmPmPaint);
             }
+
+            // Only render the day of week and date if there is no peek card, so they do not bleed
+            // into each other in ambient mode.
+            if (getPeekCardPosition().isEmpty()) {
+                // Day of week
+                canvas.drawText(
+                        mDayOfWeekFormat.format(mDate),
+                        mXOffset, mYOffset + mLineHeight, mDatePaint);
+                // Date
+                canvas.drawText(
+                        mDateFormat.format(mDate),
+                        mXOffset, mYOffset + mLineHeight * 2, mDatePaint);
+            }
         }
 
         /**
@@ -522,27 +569,23 @@
 
         @Override // DataApi.DataListener
         public void onDataChanged(DataEventBuffer dataEvents) {
-            try {
-                for (DataEvent dataEvent : dataEvents) {
-                    if (dataEvent.getType() != DataEvent.TYPE_CHANGED) {
-                        continue;
-                    }
-
-                    DataItem dataItem = dataEvent.getDataItem();
-                    if (!dataItem.getUri().getPath().equals(
-                            DigitalWatchFaceUtil.PATH_WITH_FEATURE)) {
-                        continue;
-                    }
-
-                    DataMapItem dataMapItem = DataMapItem.fromDataItem(dataItem);
-                    DataMap config = dataMapItem.getDataMap();
-                    if (Log.isLoggable(TAG, Log.DEBUG)) {
-                        Log.d(TAG, "Config DataItem updated:" + config);
-                    }
-                    updateUiForConfigDataMap(config);
+            for (DataEvent dataEvent : dataEvents) {
+                if (dataEvent.getType() != DataEvent.TYPE_CHANGED) {
+                    continue;
                 }
-            } finally {
-                dataEvents.close();
+
+                DataItem dataItem = dataEvent.getDataItem();
+                if (!dataItem.getUri().getPath().equals(
+                        DigitalWatchFaceUtil.PATH_WITH_FEATURE)) {
+                    continue;
+                }
+
+                DataMapItem dataMapItem = DataMapItem.fromDataItem(dataItem);
+                DataMap config = dataMapItem.getDataMap();
+                if (Log.isLoggable(TAG, Log.DEBUG)) {
+                    Log.d(TAG, "Config DataItem updated:" + config);
+                }
+                updateUiForConfigDataMap(config);
             }
         }
 
diff --git a/samples/browseable/WatchFace/Wearable/src/com.example.android.wearable.watchface/InteractiveWatchFaceService.java b/samples/browseable/WatchFace/Wearable/src/com.example.android.wearable.watchface/InteractiveWatchFaceService.java
new file mode 100644
index 0000000..1a6f25b
--- /dev/null
+++ b/samples/browseable/WatchFace/Wearable/src/com.example.android.wearable.watchface/InteractiveWatchFaceService.java
@@ -0,0 +1,233 @@
+/*
+ * Copyright (C) 2015 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.wearable.watchface;
+
+import android.content.res.Resources;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.graphics.Rect;
+import android.graphics.Typeface;
+import android.os.Bundle;
+import android.support.wearable.watchface.CanvasWatchFaceService;
+import android.support.wearable.watchface.WatchFaceStyle;
+import android.util.Log;
+import android.view.SurfaceHolder;
+import android.view.WindowInsets;
+
+/**
+ * Demostrates interactive watch face capabilities, i.e., touching the display and registering
+ * three different events: touch, touch-cancel and tap. The watch face UI will show the count of
+ * these events as they occur. See the {@code onTapCommand} below.
+ */
+public class InteractiveWatchFaceService extends CanvasWatchFaceService {
+
+    private static final String TAG = "InteractiveWatchFace";
+
+    private static final Typeface BOLD_TYPEFACE =
+            Typeface.create(Typeface.SANS_SERIF, Typeface.BOLD);
+    private static final Typeface NORMAL_TYPEFACE =
+            Typeface.create(Typeface.SANS_SERIF, Typeface.NORMAL);
+
+    @Override
+    public Engine onCreateEngine() {
+        return new Engine();
+    }
+
+    private class Engine extends CanvasWatchFaceService.Engine {
+
+        private Paint mTextPaint;
+        private final Paint mPeekCardBackgroundPaint = new Paint();
+
+        private float mXOffset;
+        private float mYOffset;
+        private float mTextSpacingHeight;
+        private int mScreenTextColor = Color.WHITE;
+
+        private int mTouchCommandTotal;
+        private int mTouchCancelCommandTotal;
+        private int mTapCommandTotal;
+
+        private int mTouchCoordinateX;
+        private int mTouchCoordinateY;
+
+        private final Rect mCardBounds = new Rect();
+
+        /**
+         * Whether the display supports fewer bits for each color in ambient mode. When true, we
+         * disable anti-aliasing in ambient mode.
+         */
+        private boolean mLowBitAmbient;
+
+        @Override
+        public void onCreate(SurfaceHolder holder) {
+            if (Log.isLoggable(TAG, Log.DEBUG)) {
+                Log.d(TAG, "onCreate");
+            }
+            super.onCreate(holder);
+
+            /** Accepts tap events via WatchFaceStyle (setAcceptsTapEvents(true)). */
+            setWatchFaceStyle(new WatchFaceStyle.Builder(InteractiveWatchFaceService.this)
+                    .setCardPeekMode(WatchFaceStyle.PEEK_MODE_VARIABLE)
+                    .setBackgroundVisibility(WatchFaceStyle.BACKGROUND_VISIBILITY_INTERRUPTIVE)
+                    .setShowSystemUiTime(false)
+                    .setAcceptsTapEvents(true)
+                    .build());
+
+            Resources resources = InteractiveWatchFaceService.this.getResources();
+            mTextSpacingHeight = resources.getDimension(R.dimen.interactive_text_size);
+
+            mTextPaint = new Paint();
+            mTextPaint.setColor(mScreenTextColor);
+            mTextPaint.setTypeface(BOLD_TYPEFACE);
+            mTextPaint.setAntiAlias(true);
+
+            mTouchCommandTotal = 0;
+            mTouchCancelCommandTotal = 0;
+            mTapCommandTotal = 0;
+
+            mTouchCoordinateX = 0;
+            mTouchCoordinateX = 0;
+        }
+
+        @Override
+        public void onApplyWindowInsets(WindowInsets insets) {
+            if (Log.isLoggable(TAG, Log.DEBUG)) {
+                Log.d(TAG, "onApplyWindowInsets: " + (insets.isRound() ? "round" : "square"));
+            }
+            super.onApplyWindowInsets(insets);
+
+            /** Loads offsets / text size based on device type (square vs. round). */
+            Resources resources = InteractiveWatchFaceService.this.getResources();
+            boolean isRound = insets.isRound();
+            mXOffset = resources.getDimension(
+                    isRound ? R.dimen.interactive_x_offset_round : R.dimen.interactive_x_offset);
+            mYOffset = resources.getDimension(
+                    isRound ? R.dimen.interactive_y_offset_round : R.dimen.interactive_y_offset);
+
+            float textSize = resources.getDimension(
+                    isRound ? R.dimen.interactive_text_size_round : R.dimen.interactive_text_size);
+
+            mTextPaint.setTextSize(textSize);
+        }
+
+        @Override
+        public void onPeekCardPositionUpdate(Rect bounds) {
+            super.onPeekCardPositionUpdate(bounds);
+            if (Log.isLoggable(TAG, Log.DEBUG)) {
+                Log.d(TAG, "onPeekCardPositionUpdate: " + bounds);
+            }
+            super.onPeekCardPositionUpdate(bounds);
+            if (!bounds.equals(mCardBounds)) {
+                mCardBounds.set(bounds);
+                invalidate();
+            }
+        }
+
+        @Override
+        public void onPropertiesChanged(Bundle properties) {
+            super.onPropertiesChanged(properties);
+
+            boolean burnInProtection = properties.getBoolean(PROPERTY_BURN_IN_PROTECTION, false);
+            mTextPaint.setTypeface(burnInProtection ? NORMAL_TYPEFACE : BOLD_TYPEFACE);
+
+            mLowBitAmbient = properties.getBoolean(PROPERTY_LOW_BIT_AMBIENT, false);
+
+            if (Log.isLoggable(TAG, Log.DEBUG)) {
+                Log.d(TAG, "onPropertiesChanged: burn-in protection = " + burnInProtection
+                        + ", low-bit ambient = " + mLowBitAmbient);
+            }
+        }
+
+        @Override
+        public void onAmbientModeChanged(boolean inAmbientMode) {
+            super.onAmbientModeChanged(inAmbientMode);
+            if (Log.isLoggable(TAG, Log.DEBUG)) {
+                Log.d(TAG, "onAmbientModeChanged: " + inAmbientMode);
+            }
+
+            if (mLowBitAmbient) {
+                boolean antiAlias = !inAmbientMode;
+                mTextPaint.setAntiAlias(antiAlias);
+            }
+            invalidate();
+        }
+
+        /*
+         * Captures tap event (and tap type) and increments correct tap type total.
+         */
+        @Override
+        public void onTapCommand(int tapType, int x, int y, long eventTime) {
+            if (Log.isLoggable(TAG, Log.DEBUG)) {
+                Log.d(TAG, "Tap Command: " + tapType);
+            }
+
+            mTouchCoordinateX = x;
+            mTouchCoordinateY = y;
+
+            switch(tapType) {
+                case TAP_TYPE_TOUCH:
+                    mTouchCommandTotal++;
+                    break;
+                case TAP_TYPE_TOUCH_CANCEL:
+                    mTouchCancelCommandTotal++;
+                    break;
+                case TAP_TYPE_TAP:
+                    mTapCommandTotal++;
+                    break;
+            }
+
+            invalidate();
+        }
+
+        @Override
+        public void onDraw(Canvas canvas, Rect bounds) {
+            /** Draws background */
+            canvas.drawColor(Color.BLACK);
+
+            canvas.drawText(
+                    "TAP: " + String.valueOf(mTapCommandTotal),
+                    mXOffset,
+                    mYOffset,
+                    mTextPaint);
+
+            canvas.drawText(
+                    "CANCEL: " + String.valueOf(mTouchCancelCommandTotal),
+                    mXOffset,
+                    mYOffset + mTextSpacingHeight,
+                    mTextPaint);
+
+            canvas.drawText(
+                    "TOUCH: " + String.valueOf(mTouchCommandTotal),
+                    mXOffset,
+                    mYOffset + (mTextSpacingHeight * 2),
+                    mTextPaint);
+
+            canvas.drawText(
+                    "X, Y: " + mTouchCoordinateX + ", " + mTouchCoordinateY,
+                    mXOffset,
+                    mYOffset + (mTextSpacingHeight * 3),
+                    mTextPaint
+            );
+
+            /** Covers area under peek card */
+            if (isInAmbientMode()) {
+                canvas.drawRect(mCardBounds, mPeekCardBackgroundPaint);
+            }
+        }
+    }
+}
diff --git a/samples/browseable/WatchFace/Wearable/src/com.example.android.wearable.watchface/TiltWatchFaceService.java b/samples/browseable/WatchFace/Wearable/src/com.example.android.wearable.watchface/OpenGLWatchFaceService.java
similarity index 97%
rename from samples/browseable/WatchFace/Wearable/src/com.example.android.wearable.watchface/TiltWatchFaceService.java
rename to samples/browseable/WatchFace/Wearable/src/com.example.android.wearable.watchface/OpenGLWatchFaceService.java
index ffb0b6c..01adcdb 100644
--- a/samples/browseable/WatchFace/Wearable/src/com.example.android.wearable.watchface/TiltWatchFaceService.java
+++ b/samples/browseable/WatchFace/Wearable/src/com.example.android.wearable.watchface/OpenGLWatchFaceService.java
@@ -37,15 +37,15 @@
  * {@link Gles2ColoredTriangleList}s. The camera moves around in interactive mode and stops moving
  * when the watch enters ambient mode.
  */
-public class TiltWatchFaceService extends Gles2WatchFaceService {
+public class OpenGLWatchFaceService extends Gles2WatchFaceService {
 
-    private static final String TAG = "TiltWatchFaceService";
+    private static final String TAG = "OpenGLWatchFaceService";
 
     /** Expected frame rate in interactive mode. */
     private static final long FPS = 60;
 
     /** Z distance from the camera to the watchface. */
-    private static final float EYE_Z = 2.3f;
+    private static final float EYE_Z = -2.3f;
 
     /** How long each frame is displayed at expected frame rate. */
     private static final long FRAME_PERIOD_MS = TimeUnit.SECONDS.toMillis(1) / FPS;
@@ -129,7 +129,7 @@
                 Log.d(TAG, "onCreate");
             }
             super.onCreate(surfaceHolder);
-            setWatchFaceStyle(new WatchFaceStyle.Builder(TiltWatchFaceService.this)
+            setWatchFaceStyle(new WatchFaceStyle.Builder(OpenGLWatchFaceService.this)
                     .setCardPeekMode(WatchFaceStyle.PEEK_MODE_SHORT)
                     .setBackgroundVisibility(WatchFaceStyle.BACKGROUND_VISIBILITY_INTERRUPTIVE)
                     .setStatusBarGravity(Gravity.RIGHT | Gravity.TOP)
@@ -395,7 +395,7 @@
             }
             mRegisteredTimeZoneReceiver = true;
             IntentFilter filter = new IntentFilter(Intent.ACTION_TIMEZONE_CHANGED);
-            TiltWatchFaceService.this.registerReceiver(mTimeZoneReceiver, filter);
+            OpenGLWatchFaceService.this.registerReceiver(mTimeZoneReceiver, filter);
         }
 
         private void unregisterReceiver() {
@@ -403,7 +403,7 @@
                 return;
             }
             mRegisteredTimeZoneReceiver = false;
-            TiltWatchFaceService.this.unregisterReceiver(mTimeZoneReceiver);
+            OpenGLWatchFaceService.this.unregisterReceiver(mTimeZoneReceiver);
         }
 
         @Override
diff --git a/samples/browseable/WatchFace/Wearable/src/com.example.android.wearable.watchface/SweepWatchFaceService.java b/samples/browseable/WatchFace/Wearable/src/com.example.android.wearable.watchface/SweepWatchFaceService.java
index 193f29a..0ba2ab9 100644
--- a/samples/browseable/WatchFace/Wearable/src/com.example.android.wearable.watchface/SweepWatchFaceService.java
+++ b/samples/browseable/WatchFace/Wearable/src/com.example.android.wearable.watchface/SweepWatchFaceService.java
@@ -20,14 +20,16 @@
 import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
-import android.content.res.Resources;
 import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
 import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.ColorMatrix;
+import android.graphics.ColorMatrixColorFilter;
 import android.graphics.Paint;
 import android.graphics.Rect;
-import android.graphics.drawable.BitmapDrawable;
-import android.graphics.drawable.Drawable;
 import android.os.Bundle;
+import android.support.v7.graphics.Palette;
 import android.support.wearable.watchface.CanvasWatchFaceService;
 import android.support.wearable.watchface.WatchFaceService;
 import android.support.wearable.watchface.WatchFaceStyle;
@@ -45,6 +47,7 @@
  * {@link AnalogWatchFaceService} is similar but has a ticking second hand.
  */
 public class SweepWatchFaceService extends CanvasWatchFaceService {
+
     private static final String TAG = "SweepWatchFaceService";
 
     @Override
@@ -53,32 +56,53 @@
     }
 
     private class Engine extends CanvasWatchFaceService.Engine {
-        static final float TWO_PI = (float) Math.PI * 2f;
 
-        Paint mHourPaint;
-        Paint mMinutePaint;
-        Paint mSecondPaint;
-        Paint mTickPaint;
-        boolean mMute;
-        Calendar mCalendar;
+        private static final float HOUR_STROKE_WIDTH = 5f;
+        private static final float MINUTE_STROKE_WIDTH = 3f;
+        private static final float SECOND_TICK_STROKE_WIDTH = 2f;
 
-        final BroadcastReceiver mTimeZoneReceiver = new BroadcastReceiver() {
+        private static final float CENTER_GAP_AND_CIRCLE_RADIUS = 4f;
+
+        private static final int SHADOW_RADIUS = 6;
+
+        private Calendar mCalendar;
+        private boolean mRegisteredTimeZoneReceiver = false;
+        private boolean mMuteMode;
+
+        private float mCenterX;
+        private float mCenterY;
+
+        private float mSecondHandLength;
+        private float mMinuteHandLength;
+        private float mHourHandLength;
+
+        /* Colors for all hands (hour, minute, seconds, ticks) based on photo loaded. */
+        private int mWatchHandColor;
+        private int mWatchHandHightlightColor;
+        private int mWatchHandShadowColor;
+
+        private Paint mHourPaint;
+        private Paint mMinutePaint;
+        private Paint mSecondPaint;
+        private Paint mTickAndCirclePaint;
+
+        private Paint mBackgroundPaint;
+        private Bitmap mBackgroundBitmap;
+        private Bitmap mGrayBackgroundBitmap;
+
+        private boolean mAmbient;
+        private boolean mLowBitAmbient;
+        private boolean mBurnInProtection;
+
+        private Rect mPeekCardBounds = new Rect();
+
+        private final BroadcastReceiver mTimeZoneReceiver = new BroadcastReceiver() {
             @Override
             public void onReceive(Context context, Intent intent) {
                 mCalendar.setTimeZone(TimeZone.getDefault());
                 invalidate();
             }
         };
-        boolean mRegisteredTimeZoneReceiver = false;
-
-        /**
-         * Whether the display supports fewer bits for each color in ambient mode. When true, we
-         * disable anti-aliasing in ambient mode.
-         */
-        boolean mLowBitAmbient;
-
-        Bitmap mBackgroundBitmap;
-        Bitmap mBackgroundScaledBitmap;
 
         @Override
         public void onCreate(SurfaceHolder holder) {
@@ -93,32 +117,61 @@
                     .setShowSystemUiTime(false)
                     .build());
 
-            Resources resources = SweepWatchFaceService.this.getResources();
-            Drawable backgroundDrawable = resources.getDrawable(R.drawable.bg, null /* theme */);
-            mBackgroundBitmap = ((BitmapDrawable) backgroundDrawable).getBitmap();
+            mBackgroundPaint = new Paint();
+            mBackgroundPaint.setColor(Color.BLACK);
+            mBackgroundBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.bg);
+
+            /* Set defaults for colors */
+            mWatchHandColor = Color.WHITE;
+            mWatchHandHightlightColor = Color.RED;
+            mWatchHandShadowColor = Color.BLACK;
 
             mHourPaint = new Paint();
-            mHourPaint.setARGB(255, 200, 200, 200);
-            mHourPaint.setStrokeWidth(5.f);
+            mHourPaint.setColor(mWatchHandColor);
+            mHourPaint.setStrokeWidth(HOUR_STROKE_WIDTH);
             mHourPaint.setAntiAlias(true);
             mHourPaint.setStrokeCap(Paint.Cap.ROUND);
+            mHourPaint.setShadowLayer(SHADOW_RADIUS, 0, 0, mWatchHandShadowColor);
 
             mMinutePaint = new Paint();
-            mMinutePaint.setARGB(255, 200, 200, 200);
-            mMinutePaint.setStrokeWidth(3.f);
+            mMinutePaint.setColor(mWatchHandColor);
+            mMinutePaint.setStrokeWidth(MINUTE_STROKE_WIDTH);
             mMinutePaint.setAntiAlias(true);
             mMinutePaint.setStrokeCap(Paint.Cap.ROUND);
+            mMinutePaint.setShadowLayer(SHADOW_RADIUS, 0, 0, mWatchHandShadowColor);
 
             mSecondPaint = new Paint();
-            mSecondPaint.setARGB(255, 255, 0, 0);
-            mSecondPaint.setStrokeWidth(2.f);
+            mSecondPaint.setColor(mWatchHandHightlightColor);
+            mSecondPaint.setStrokeWidth(SECOND_TICK_STROKE_WIDTH);
             mSecondPaint.setAntiAlias(true);
             mSecondPaint.setStrokeCap(Paint.Cap.ROUND);
+            mSecondPaint.setShadowLayer(SHADOW_RADIUS, 0, 0, mWatchHandShadowColor);
 
-            mTickPaint = new Paint();
-            mTickPaint.setARGB(100, 255, 255, 255);
-            mTickPaint.setStrokeWidth(2.f);
-            mTickPaint.setAntiAlias(true);
+            mTickAndCirclePaint = new Paint();
+            mTickAndCirclePaint.setColor(mWatchHandColor);
+            mTickAndCirclePaint.setStrokeWidth(SECOND_TICK_STROKE_WIDTH);
+            mTickAndCirclePaint.setAntiAlias(true);
+            mTickAndCirclePaint.setStyle(Paint.Style.STROKE);
+            mTickAndCirclePaint.setShadowLayer(SHADOW_RADIUS, 0, 0, mWatchHandShadowColor);
+
+            /* Extract colors from background image to improve watchface style. */
+            Palette.generateAsync(
+                    mBackgroundBitmap,
+                    new Palette.PaletteAsyncListener() {
+                        @Override
+                        public void onGenerated(Palette palette) {
+                            if (palette != null) {
+                                if (Log.isLoggable(TAG, Log.DEBUG)) {
+                                    Log.d(TAG, "Palette: " + palette);
+                                }
+
+                                mWatchHandHightlightColor = palette.getVibrantColor(Color.RED);
+                                mWatchHandColor = palette.getLightVibrantColor(Color.WHITE);
+                                mWatchHandShadowColor = palette.getDarkMutedColor(Color.BLACK);
+                                updateWatchHandStyle();
+                            }
+                        }
+                    });
 
             mCalendar = Calendar.getInstance();
         }
@@ -126,18 +179,17 @@
         @Override
         public void onPropertiesChanged(Bundle properties) {
             super.onPropertiesChanged(properties);
-            mLowBitAmbient = properties.getBoolean(PROPERTY_LOW_BIT_AMBIENT, false);
             if (Log.isLoggable(TAG, Log.DEBUG)) {
                 Log.d(TAG, "onPropertiesChanged: low-bit ambient = " + mLowBitAmbient);
             }
+
+            mLowBitAmbient = properties.getBoolean(PROPERTY_LOW_BIT_AMBIENT, false);
+            mBurnInProtection = properties.getBoolean(PROPERTY_BURN_IN_PROTECTION, false);
         }
 
         @Override
         public void onTimeTick() {
             super.onTimeTick();
-            if (Log.isLoggable(TAG, Log.DEBUG)) {
-                Log.d(TAG, "onTimeTick: ambient = " + isInAmbientMode());
-            }
             invalidate();
         }
 
@@ -147,22 +199,56 @@
             if (Log.isLoggable(TAG, Log.DEBUG)) {
                 Log.d(TAG, "onAmbientModeChanged: " + inAmbientMode);
             }
-            if (mLowBitAmbient) {
-                boolean antiAlias = !inAmbientMode;
-                mHourPaint.setAntiAlias(antiAlias);
-                mMinutePaint.setAntiAlias(antiAlias);
-                mSecondPaint.setAntiAlias(antiAlias);
-                mTickPaint.setAntiAlias(antiAlias);
-            }
+            mAmbient = inAmbientMode;
+
+            updateWatchHandStyle();
+
             invalidate();
         }
 
+        private void updateWatchHandStyle(){
+            if (mAmbient){
+                mHourPaint.setColor(Color.WHITE);
+                mMinutePaint.setColor(Color.WHITE);
+                mSecondPaint.setColor(Color.WHITE);
+                mTickAndCirclePaint.setColor(Color.WHITE);
+
+                mHourPaint.setAntiAlias(false);
+                mMinutePaint.setAntiAlias(false);
+                mSecondPaint.setAntiAlias(false);
+                mTickAndCirclePaint.setAntiAlias(false);
+
+                mHourPaint.clearShadowLayer();
+                mMinutePaint.clearShadowLayer();
+                mSecondPaint.clearShadowLayer();
+                mTickAndCirclePaint.clearShadowLayer();
+
+            } else {
+                mHourPaint.setColor(mWatchHandColor);
+                mMinutePaint.setColor(mWatchHandColor);
+                mSecondPaint.setColor(mWatchHandHightlightColor);
+                mTickAndCirclePaint.setColor(mWatchHandColor);
+
+                mHourPaint.setAntiAlias(true);
+                mMinutePaint.setAntiAlias(true);
+                mSecondPaint.setAntiAlias(true);
+                mTickAndCirclePaint.setAntiAlias(true);
+
+                mHourPaint.setShadowLayer(SHADOW_RADIUS, 0, 0, mWatchHandShadowColor);
+                mMinutePaint.setShadowLayer(SHADOW_RADIUS, 0, 0, mWatchHandShadowColor);
+                mSecondPaint.setShadowLayer(SHADOW_RADIUS, 0, 0, mWatchHandShadowColor);
+                mTickAndCirclePaint.setShadowLayer(SHADOW_RADIUS, 0, 0, mWatchHandShadowColor);
+            }
+        }
+
         @Override
         public void onInterruptionFilterChanged(int interruptionFilter) {
             super.onInterruptionFilterChanged(interruptionFilter);
             boolean inMuteMode = (interruptionFilter == WatchFaceService.INTERRUPTION_FILTER_NONE);
-            if (mMute != inMuteMode) {
-                mMute = inMuteMode;
+
+            /* Dim display in mute mode. */
+            if (mMuteMode != inMuteMode) {
+                mMuteMode = inMuteMode;
                 mHourPaint.setAlpha(inMuteMode ? 100 : 255);
                 mMinutePaint.setAlpha(inMuteMode ? 100 : 255);
                 mSecondPaint.setAlpha(inMuteMode ? 80 : 255);
@@ -171,6 +257,62 @@
         }
 
         @Override
+        public void onSurfaceChanged(SurfaceHolder holder, int format, int width, int height) {
+            super.onSurfaceChanged(holder, format, width, height);
+
+            /*
+             * Find the coordinates of the center point on the screen, and ignore the window
+             * insets, so that, on round watches with a "chin", the watch face is centered on the
+             * entire screen, not just the usable portion.
+             */
+            mCenterX = width / 2f;
+            mCenterY = height / 2f;
+
+            /*
+             * Calculate lengths of different hands based on watch screen size.
+             */
+            mSecondHandLength = (float) (mCenterX * 0.875);
+            mMinuteHandLength = (float) (mCenterX * 0.75);
+            mHourHandLength = (float) (mCenterX * 0.5);
+
+
+            /* Scale loaded background image (more efficient) if surface dimensions change. */
+            float scale = ((float) width) / (float) mBackgroundBitmap.getWidth();
+
+            mBackgroundBitmap = Bitmap.createScaledBitmap(mBackgroundBitmap,
+                    (int) (mBackgroundBitmap.getWidth() * scale),
+                    (int) (mBackgroundBitmap.getHeight() * scale), true);
+
+            /*
+             * Create a gray version of the image only if it will look nice on the device in
+             * ambient mode. That means we don't want devices that support burn-in
+             * protection (slight movements in pixels, not great for images going all the way to
+             * edges) and low ambient mode (degrades image quality).
+             *
+             * Also, if your watch face will know about all images ahead of time (users aren't
+             * selecting their own photos for the watch face), it will be more
+             * efficient to create a black/white version (png, etc.) and load that when you need it.
+             */
+            if (!mBurnInProtection && !mLowBitAmbient) {
+                initGrayBackgroundBitmap();
+            }
+        }
+
+        private void initGrayBackgroundBitmap() {
+            mGrayBackgroundBitmap = Bitmap.createBitmap(
+                    mBackgroundBitmap.getWidth(),
+                    mBackgroundBitmap.getHeight(),
+                    Bitmap.Config.ARGB_8888);
+            Canvas canvas = new Canvas(mGrayBackgroundBitmap);
+            Paint grayPaint = new Paint();
+            ColorMatrix colorMatrix = new ColorMatrix();
+            colorMatrix.setSaturation(0);
+            ColorMatrixColorFilter filter = new ColorMatrixColorFilter(colorMatrix);
+            grayPaint.setColorFilter(filter);
+            canvas.drawBitmap(mBackgroundBitmap, 0, 0, grayPaint);
+        }
+
+        @Override
         public void onDraw(Canvas canvas, Rect bounds) {
             if (Log.isLoggable(TAG, Log.VERBOSE)) {
                 Log.v(TAG, "onDraw");
@@ -178,65 +320,95 @@
             long now = System.currentTimeMillis();
             mCalendar.setTimeInMillis(now);
 
-            int width = bounds.width();
-            int height = bounds.height();
-
-            // Draw the background, scaled to fit.
-            if (mBackgroundScaledBitmap == null
-                    || mBackgroundScaledBitmap.getWidth() != width
-                    || mBackgroundScaledBitmap.getHeight() != height) {
-                mBackgroundScaledBitmap = Bitmap.createScaledBitmap(mBackgroundBitmap,
-                        width, height, true /* filter */);
+            if (mAmbient && (mLowBitAmbient || mBurnInProtection)) {
+                canvas.drawColor(Color.BLACK);
+            } else if (mAmbient) {
+                canvas.drawBitmap(mGrayBackgroundBitmap, 0, 0, mBackgroundPaint);
+            } else {
+                canvas.drawBitmap(mBackgroundBitmap, 0, 0, mBackgroundPaint);
             }
-            canvas.drawBitmap(mBackgroundScaledBitmap, 0, 0, null);
 
-            // Find the center. Ignore the window insets so that, on round watches with a
-            // "chin", the watch face is centered on the entire screen, not just the usable
-            // portion.
-            float centerX = width / 2f;
-            float centerY = height / 2f;
-
-            // Draw the ticks.
-            float innerTickRadius = centerX - 10;
-            float outerTickRadius = centerX;
+            /*
+             * Draw ticks. Usually you will want to bake this directly into the photo, but in
+             * cases where you want to allow users to select their own photos, this dynamically
+             * creates them on top of the photo.
+             */
+            float innerTickRadius = mCenterX - 10;
+            float outerTickRadius = mCenterX;
             for (int tickIndex = 0; tickIndex < 12; tickIndex++) {
                 float tickRot = (float) (tickIndex * Math.PI * 2 / 12);
                 float innerX = (float) Math.sin(tickRot) * innerTickRadius;
                 float innerY = (float) -Math.cos(tickRot) * innerTickRadius;
                 float outerX = (float) Math.sin(tickRot) * outerTickRadius;
                 float outerY = (float) -Math.cos(tickRot) * outerTickRadius;
-                canvas.drawLine(centerX + innerX, centerY + innerY,
-                        centerX + outerX, centerY + outerY, mTickPaint);
+                canvas.drawLine(mCenterX + innerX, mCenterY + innerY,
+                        mCenterX + outerX, mCenterY + outerY, mTickAndCirclePaint);
             }
 
-            float seconds =
-                    mCalendar.get(Calendar.SECOND) + mCalendar.get(Calendar.MILLISECOND) / 1000f;
-            float secRot = seconds / 60f * TWO_PI;
-            float minutes = mCalendar.get(Calendar.MINUTE) + seconds / 60f;
-            float minRot = minutes / 60f * TWO_PI;
-            float hours = mCalendar.get(Calendar.HOUR) + minutes / 60f;
-            float hrRot = hours / 12f * TWO_PI;
+            /*
+             * These calculations reflect the rotation in degrees per unit of time, e.g.,
+             * 360 / 60 = 6 and 360 / 12 = 30.
+             */
+            final float seconds =
+                    (mCalendar.get(Calendar.SECOND) + mCalendar.get(Calendar.MILLISECOND) / 1000f);
+            final float secondsRotation = seconds * 6f;
 
-            float secLength = centerX - 20;
-            float minLength = centerX - 40;
-            float hrLength = centerX - 80;
+            final float minutesRotation = mCalendar.get(Calendar.MINUTE) * 6f;
 
-            if (!isInAmbientMode()) {
-                float secX = (float) Math.sin(secRot) * secLength;
-                float secY = (float) -Math.cos(secRot) * secLength;
-                canvas.drawLine(centerX, centerY, centerX + secX, centerY + secY, mSecondPaint);
+            final float hourHandOffset = mCalendar.get(Calendar.MINUTE) / 2f;
+            final float hoursRotation = (mCalendar.get(Calendar.HOUR) * 30) + hourHandOffset;
+
+            /*
+             * Save the canvas state before we can begin to rotate it.
+             */
+            canvas.save();
+
+            canvas.rotate(hoursRotation, mCenterX, mCenterY);
+            canvas.drawLine(
+                    mCenterX,
+                    mCenterY - CENTER_GAP_AND_CIRCLE_RADIUS,
+                    mCenterX,
+                    mCenterY - mHourHandLength,
+                    mHourPaint);
+
+            canvas.rotate(minutesRotation - hoursRotation, mCenterX, mCenterY);
+            canvas.drawLine(
+                    mCenterX,
+                    mCenterY - CENTER_GAP_AND_CIRCLE_RADIUS,
+                    mCenterX,
+                    mCenterY - mMinuteHandLength,
+                    mMinutePaint);
+
+            /*
+             * Ensure the "seconds" hand is drawn only when we are in interactive mode.
+             * Otherwise, we only update the watch face once a minute.
+             */
+            if (!mAmbient) {
+                canvas.rotate(secondsRotation - minutesRotation, mCenterX, mCenterY);
+                canvas.drawLine(
+                        mCenterX,
+                        mCenterY - CENTER_GAP_AND_CIRCLE_RADIUS,
+                        mCenterX,
+                        mCenterY - mSecondHandLength,
+                        mSecondPaint);
+
+            }
+            canvas.drawCircle(
+                    mCenterX,
+                    mCenterY,
+                    CENTER_GAP_AND_CIRCLE_RADIUS,
+                    mTickAndCirclePaint);
+
+            /* Restore the canvas' original orientation. */
+            canvas.restore();
+
+            /* Draw rectangle behind peek card in ambient mode to improve readability. */
+            if (mAmbient) {
+                canvas.drawRect(mPeekCardBounds, mBackgroundPaint);
             }
 
-            float minX = (float) Math.sin(minRot) * minLength;
-            float minY = (float) -Math.cos(minRot) * minLength;
-            canvas.drawLine(centerX, centerY, centerX + minX, centerY + minY, mMinutePaint);
-
-            float hrX = (float) Math.sin(hrRot) * hrLength;
-            float hrY = (float) -Math.cos(hrRot) * hrLength;
-            canvas.drawLine(centerX, centerY, centerX + hrX, centerY + hrY, mHourPaint);
-
-            // Draw every frame as long as we're visible and in interactive mode.
-            if (isVisible() && !isInAmbientMode()) {
+            /* Draw every frame as long as we're visible and in interactive mode. */
+            if ((isVisible()) && (!mAmbient)) {
                 invalidate();
             }
         }
@@ -247,16 +419,20 @@
 
             if (visible) {
                 registerReceiver();
-
-                // Update time zone in case it changed while we weren't visible.
+                /* Update time zone in case it changed while we weren't visible. */
                 mCalendar.setTimeZone(TimeZone.getDefault());
-
                 invalidate();
             } else {
                 unregisterReceiver();
             }
         }
 
+        @Override
+        public void onPeekCardPositionUpdate(Rect rect) {
+            super.onPeekCardPositionUpdate(rect);
+            mPeekCardBounds.set(rect);
+        }
+
         private void registerReceiver() {
             if (mRegisteredTimeZoneReceiver) {
                 return;
diff --git a/samples/browseable/WatchFace/_index.jd b/samples/browseable/WatchFace/_index.jd
index 8c803fa..8b779d0 100644
--- a/samples/browseable/WatchFace/_index.jd
+++ b/samples/browseable/WatchFace/_index.jd
@@ -7,7 +7,7 @@
             
 This sample demonstrates how to create watch faces for android wear and includes a phone app
 and a wearable app. The wearable app has a variety of watch faces including analog, digital,
-opengl, calendar, etc. It also includes a watch-side configuration example. The phone app
-includes a phone-side configuration example.
+opengl, calendar, interactive, etc. It also includes a watch-side configuration example.
+The phone app includes a phone-side configuration example.
             
         </p>
diff --git a/samples/browseable/XYZTouristAttractions/Application/res/layout/fragment_detail.xml b/samples/browseable/XYZTouristAttractions/Application/res/layout/fragment_detail.xml
index dffeb4e..6e280fd 100644
--- a/samples/browseable/XYZTouristAttractions/Application/res/layout/fragment_detail.xml
+++ b/samples/browseable/XYZTouristAttractions/Application/res/layout/fragment_detail.xml
@@ -16,67 +16,86 @@
   limitations under the License.
   -->
 
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:orientation="vertical"
+<android.support.design.widget.CoordinatorLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
     android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:weightSum="100">
-
-    <ImageView
-        android:id="@+id/imageView"
-        android:layout_width="match_parent"
-        android:layout_height="0dp"
-        android:layout_weight="50"
-        android:scaleType="centerCrop"
-        android:transitionName="image" />
+    android:layout_height="match_parent">
 
     <LinearLayout
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:background="?colorPrimary"
         android:orientation="vertical"
-        android:paddingStart="@dimen/keyline2"
-        android:paddingEnd="@dimen/keyline3"
-        android:paddingTop="@dimen/standard_margin"
-        android:paddingBottom="@dimen/standard_margin"
-        android:elevation="2dp">
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:weightSum="100">
 
-        <TextView
-            android:id="@+id/nameTextView"
+        <ImageView
+            android:id="@+id/imageView"
+            android:layout_width="match_parent"
+            android:layout_height="0dp"
+            android:layout_weight="50"
+            android:scaleType="centerCrop"
+            android:transitionName="image" />
+
+        <LinearLayout
+            android:id="@+id/textLayout"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:maxLines="2"
-            android:ellipsize="end"
-            android:textIsSelectable="true"
-            style="@style/TextAppearance.AppCompat.Title.Inverse"
-            android:transitionName="title" />
+            android:background="?colorPrimary"
+            android:orientation="vertical"
+            android:paddingStart="@dimen/keyline2"
+            android:paddingEnd="@dimen/keyline3"
+            android:paddingTop="@dimen/standard_margin"
+            android:paddingBottom="@dimen/standard_margin"
+            android:elevation="2dp">
 
-        <TextView
-            android:id="@+id/distanceTextView"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            style="@style/TextAppearance.AppCompat.Subhead.Inverse" />
+            <TextView
+                android:id="@+id/nameTextView"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:maxLines="2"
+                android:ellipsize="end"
+                android:textIsSelectable="true"
+                style="@style/TextAppearance.AppCompat.Title.Inverse" />
+
+            <TextView
+                android:id="@+id/distanceTextView"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                style="@style/TextAppearance.AppCompat.Subhead.Inverse" />
+
+        </LinearLayout>
+
+        <ScrollView
+            android:layout_width="match_parent"
+            android:layout_height="0dp"
+            android:layout_weight="50"
+            android:paddingTop="@dimen/standard_margin"
+            android:paddingBottom="@dimen/standard_margin"
+            android:scrollbarStyle="outsideOverlay"
+            android:clipToPadding="false">
+
+            <TextView
+                android:id="@+id/descriptionTextView"
+                android:layout_height="wrap_content"
+                android:layout_width="match_parent"
+                android:textIsSelectable="true"
+                style="@style/TextAppearance.AppCompat.Body1"
+                android:paddingStart="@dimen/keyline2"
+                android:paddingEnd="@dimen/keyline3" />
+
+        </ScrollView>
 
     </LinearLayout>
-    
-    <ScrollView
-        android:layout_width="match_parent"
-        android:layout_height="0dp"
-        android:layout_weight="50"
-        android:paddingTop="@dimen/standard_margin"
-        android:paddingBottom="@dimen/standard_margin"
-        android:scrollbarStyle="outsideOverlay"
-        android:clipToPadding="false">
 
-        <TextView
-            android:id="@+id/descriptionTextView"
-            android:layout_height="wrap_content"
-            android:layout_width="match_parent"
-            android:textIsSelectable="true"
-            style="@style/TextAppearance.AppCompat.Body1"
-            android:paddingStart="@dimen/keyline2"
-            android:paddingEnd="@dimen/keyline3" />
+    <android.support.design.widget.FloatingActionButton
+        android:id="@+id/mapFab"
+        android:layout_height="wrap_content"
+        android:layout_width="wrap_content"
+        android:src="@drawable/ic_action_map"
+        app:layout_anchor="@id/textLayout"
+        app:layout_anchorGravity="bottom|start"
+        app:rippleColor="@color/colorFabRipple"
+        android:layout_marginStart="@dimen/fab_margin"
+        android:clickable="true" />
 
-    </ScrollView>
-
-</LinearLayout>
\ No newline at end of file
+</android.support.design.widget.CoordinatorLayout>
\ No newline at end of file
diff --git a/samples/browseable/XYZTouristAttractions/Application/res/layout/list_row.xml b/samples/browseable/XYZTouristAttractions/Application/res/layout/list_row.xml
index 25f55d0..b2cef57 100644
--- a/samples/browseable/XYZTouristAttractions/Application/res/layout/list_row.xml
+++ b/samples/browseable/XYZTouristAttractions/Application/res/layout/list_row.xml
@@ -49,21 +49,20 @@
             android:id="@android:id/text1"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:layout_toRightOf="@android:id/icon"
+            android:layout_toEndOf="@android:id/icon"
             android:paddingTop="@dimen/small_margin"
             android:paddingLeft="@dimen/small_margin"
             android:paddingRight="@dimen/small_margin"
             android:maxLines="1"
             android:ellipsize="end"
             style="?android:textAppearanceMedium"
-            tools:text="Title 1"
-            android:transitionName="image" />
+            tools:text="Title 1" />
 
         <TextView
             android:id="@android:id/text2"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:layout_toRightOf="@android:id/icon"
+            android:layout_toEndOf="@android:id/icon"
             android:layout_below="@android:id/text1"
             android:padding="@dimen/small_margin"
             android:ellipsize="end"
diff --git a/samples/browseable/XYZTouristAttractions/Application/res/menu/detail.xml b/samples/browseable/XYZTouristAttractions/Application/res/menu/detail.xml
deleted file mode 100644
index aeb5c98..0000000
--- a/samples/browseable/XYZTouristAttractions/Application/res/menu/detail.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<!--
-  Copyright 2015 Google Inc. All rights reserved.
-
-  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.
-  -->
-
-<menu xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
-    xmlns:tools="http://schemas.android.com/tools"
-    tools:context=".MainActivity" >
-
-    <item android:id="@+id/map"
-        android:title="@string/action_map"
-        android:orderInCategory="100"
-        android:icon="@drawable/ic_action_map"
-        app:showAsAction="ifRoom" />
-
-</menu>
diff --git a/samples/browseable/XYZTouristAttractions/Application/res/transition-v21/shared_move.xml b/samples/browseable/XYZTouristAttractions/Application/res/transition-v21/shared_move.xml
new file mode 100644
index 0000000..3debfa0
--- /dev/null
+++ b/samples/browseable/XYZTouristAttractions/Application/res/transition-v21/shared_move.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2014 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.
+-->
+<transitionSet xmlns:android="http://schemas.android.com/apk/res/android"
+    android:startDelay="@android:integer/config_shortAnimTime">
+
+    <changeBounds>
+        <arcMotion />
+    </changeBounds>
+    <changeTransform/>
+    <changeClipBounds/>
+    <changeImageTransform/>
+
+</transitionSet>
diff --git a/samples/browseable/XYZTouristAttractions/Application/res/transition-v21/explode.xml b/samples/browseable/XYZTouristAttractions/Application/res/transition-v21/window_enter.xml
similarity index 77%
rename from samples/browseable/XYZTouristAttractions/Application/res/transition-v21/explode.xml
rename to samples/browseable/XYZTouristAttractions/Application/res/transition-v21/window_enter.xml
index 5dfa717..619ffdf 100644
--- a/samples/browseable/XYZTouristAttractions/Application/res/transition-v21/explode.xml
+++ b/samples/browseable/XYZTouristAttractions/Application/res/transition-v21/window_enter.xml
@@ -14,7 +14,8 @@
   See the License for the specific language governing permissions and
   limitations under the License.
   -->
-<transitionSet xmlns:android="http://schemas.android.com/apk/res/android">
+<transitionSet xmlns:android="http://schemas.android.com/apk/res/android"
+    android:transitionOrdering="sequential">
 
     <explode>
         <targets>
@@ -25,4 +26,11 @@
         </targets>
     </explode>
 
+    <transition class="com.example.android.xyztouristattractions.ui.ScaleTransition"
+        android:interpolator="@android:interpolator/overshoot">
+        <targets>
+            <target android:targetId="@id/mapFab" />
+        </targets>
+    </transition>
+
 </transitionSet>
\ No newline at end of file
diff --git a/samples/browseable/XYZTouristAttractions/Application/res/transition-v21/explode.xml b/samples/browseable/XYZTouristAttractions/Application/res/transition-v21/window_return.xml
similarity index 70%
copy from samples/browseable/XYZTouristAttractions/Application/res/transition-v21/explode.xml
copy to samples/browseable/XYZTouristAttractions/Application/res/transition-v21/window_return.xml
index 5dfa717..0dae377 100644
--- a/samples/browseable/XYZTouristAttractions/Application/res/transition-v21/explode.xml
+++ b/samples/browseable/XYZTouristAttractions/Application/res/transition-v21/window_return.xml
@@ -14,7 +14,16 @@
   See the License for the specific language governing permissions and
   limitations under the License.
   -->
-<transitionSet xmlns:android="http://schemas.android.com/apk/res/android">
+<transitionSet xmlns:android="http://schemas.android.com/apk/res/android"
+    android:transitionOrdering="sequential">
+
+    <transition class="com.example.android.xyztouristattractions.ui.ScaleTransition"
+        android:interpolator="@android:interpolator/fast_out_linear_in"
+        android:duration="@android:integer/config_shortAnimTime">
+        <targets>
+            <target android:targetId="@id/mapFab" />
+        </targets>
+    </transition>
 
     <explode>
         <targets>
@@ -22,6 +31,7 @@
             <target android:targetClass="android.widget.FrameLayout" />
             <target android:targetClass="android.widget.LinearLayout" />
             <target android:targetClass="android.widget.ImageView" />
+            <target android:excludeId="@id/mapFab" />
         </targets>
     </explode>
 
diff --git a/samples/browseable/XYZTouristAttractions/Application/res/values-sw400dp-v21/dimens.xml b/samples/browseable/XYZTouristAttractions/Application/res/values-sw400dp-v21/dimens.xml
new file mode 100644
index 0000000..ce539e4
--- /dev/null
+++ b/samples/browseable/XYZTouristAttractions/Application/res/values-sw400dp-v21/dimens.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  Copyright 2015 Google Inc. All rights reserved.
+
+  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.
+  -->
+
+<resources>
+
+    <dimen name="fab_margin">12dp</dimen>
+
+</resources>
\ No newline at end of file
diff --git a/samples/browseable/XYZTouristAttractions/Application/res/values-sw400dp/dimens.xml b/samples/browseable/XYZTouristAttractions/Application/res/values-sw400dp/dimens.xml
index ad90eaa..701be7d 100644
--- a/samples/browseable/XYZTouristAttractions/Application/res/values-sw400dp/dimens.xml
+++ b/samples/browseable/XYZTouristAttractions/Application/res/values-sw400dp/dimens.xml
@@ -20,5 +20,6 @@
     <dimen name="small_margin">12dp</dimen>
     <dimen name="tiny_margin">8dp</dimen>
     <dimen name="image_size">140dp</dimen>
+    <dimen name="fab_margin">0dp</dimen>
 
 </resources>
diff --git a/samples/browseable/XYZTouristAttractions/Application/res/values-v11/template-styles.xml b/samples/browseable/XYZTouristAttractions/Application/res/values-v11/template-styles.xml
index 8c1ea66..f261bb5 100644
--- a/samples/browseable/XYZTouristAttractions/Application/res/values-v11/template-styles.xml
+++ b/samples/browseable/XYZTouristAttractions/Application/res/values-v11/template-styles.xml
@@ -17,6 +17,6 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Holo.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
 </resources>
diff --git a/samples/browseable/XYZTouristAttractions/Application/res/values-v21/base-template-styles.xml b/samples/browseable/XYZTouristAttractions/Application/res/values-v21/base-template-styles.xml
index c778e4f..d838f98 100644
--- a/samples/browseable/XYZTouristAttractions/Application/res/values-v21/base-template-styles.xml
+++ b/samples/browseable/XYZTouristAttractions/Application/res/values-v21/base-template-styles.xml
@@ -18,7 +18,7 @@
 <resources>
 
     <!-- Activity themes -->
-    <style name="Theme.Base" parent="android:Theme.Material.Light">
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light">
     </style>
 
 </resources>
diff --git a/samples/browseable/XYZTouristAttractions/Application/res/values-v21/dimens.xml b/samples/browseable/XYZTouristAttractions/Application/res/values-v21/dimens.xml
new file mode 100644
index 0000000..2704c45
--- /dev/null
+++ b/samples/browseable/XYZTouristAttractions/Application/res/values-v21/dimens.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  Copyright 2015 Google Inc. All rights reserved.
+
+  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.
+  -->
+
+<resources>
+
+    <dimen name="fab_margin">8dp</dimen>
+
+</resources>
\ No newline at end of file
diff --git a/samples/browseable/XYZTouristAttractions/Application/res/values-v21/styles.xml b/samples/browseable/XYZTouristAttractions/Application/res/values-v21/styles.xml
index 319d664..d1221c5 100644
--- a/samples/browseable/XYZTouristAttractions/Application/res/values-v21/styles.xml
+++ b/samples/browseable/XYZTouristAttractions/Application/res/values-v21/styles.xml
@@ -21,8 +21,10 @@
         <item name="android:windowActivityTransitions">true</item>
         <item name="android:windowExitTransition">@transition/fade</item>
         <item name="android:windowReenterTransition">@transition/fade</item>
-        <item name="android:windowEnterTransition">@transition/explode</item>
-        <item name="android:windowReturnTransition">@transition/explode</item>
+        <item name="android:windowEnterTransition">@transition/window_enter</item>
+        <item name="android:windowReturnTransition">@transition/window_return</item>
+        <item name="android:windowSharedElementEnterTransition">@transition/shared_move</item>
+        <item name="android:windowSharedElementExitTransition">@transition/shared_move</item>
         <item name="android:windowAllowEnterTransitionOverlap">false</item>
         <item name="android:windowAllowReturnTransitionOverlap">false</item>
         <item name="android:windowSharedElementsUseOverlay">false</item>
diff --git a/samples/browseable/XYZTouristAttractions/Application/res/values/dimens.xml b/samples/browseable/XYZTouristAttractions/Application/res/values/dimens.xml
index 03acfef..9cfc825 100644
--- a/samples/browseable/XYZTouristAttractions/Application/res/values/dimens.xml
+++ b/samples/browseable/XYZTouristAttractions/Application/res/values/dimens.xml
@@ -21,6 +21,7 @@
     <dimen name="small_margin">8dp</dimen>
     <dimen name="tiny_margin">4dp</dimen>
     <dimen name="image_size">120dp</dimen>
+    <dimen name="fab_margin">-8dp</dimen>
     <item type="dimen" name="keyline1">@dimen/standard_margin</item>
     <dimen name="keyline2">72dp</dimen>
     <item type="dimen" name="keyline3">@dimen/standard_margin</item>
diff --git a/samples/browseable/XYZTouristAttractions/Application/res/values/template-styles.xml b/samples/browseable/XYZTouristAttractions/Application/res/values/template-styles.xml
index 6e7d593..74086d2 100644
--- a/samples/browseable/XYZTouristAttractions/Application/res/values/template-styles.xml
+++ b/samples/browseable/XYZTouristAttractions/Application/res/values/template-styles.xml
@@ -18,7 +18,7 @@
 
     <!-- Activity themes -->
 
-    <style name="Theme.Base" parent="android:Theme.Light" />
+    <style name="Theme.Base" parent="@style/Theme.AppCompat.Light" />
 
     <style name="Theme.Sample" parent="Theme.Base" />
 
diff --git a/samples/browseable/XYZTouristAttractions/Application/src/com.example.android.xyztouristattractions/ui/AttractionListFragment.java b/samples/browseable/XYZTouristAttractions/Application/src/com.example.android.xyztouristattractions/ui/AttractionListFragment.java
index 0f1bc8b..28f9127 100644
--- a/samples/browseable/XYZTouristAttractions/Application/src/com.example.android.xyztouristattractions/ui/AttractionListFragment.java
+++ b/samples/browseable/XYZTouristAttractions/Application/src/com.example.android.xyztouristattractions/ui/AttractionListFragment.java
@@ -216,7 +216,7 @@
 
         @Override
         public void onClick(View v) {
-            mItemClickListener.onItemClick(v, getPosition());
+            mItemClickListener.onItemClick(v, getAdapterPosition());
         }
     }
 
diff --git a/samples/browseable/XYZTouristAttractions/Application/src/com.example.android.xyztouristattractions/ui/DetailFragment.java b/samples/browseable/XYZTouristAttractions/Application/src/com.example.android.xyztouristattractions/ui/DetailFragment.java
index 4d21009..1ab7326 100644
--- a/samples/browseable/XYZTouristAttractions/Application/src/com.example.android.xyztouristattractions/ui/DetailFragment.java
+++ b/samples/browseable/XYZTouristAttractions/Application/src/com.example.android.xyztouristattractions/ui/DetailFragment.java
@@ -21,12 +21,11 @@
 import android.net.Uri;
 import android.os.Build;
 import android.os.Bundle;
+import android.support.design.widget.FloatingActionButton;
 import android.support.v4.app.Fragment;
 import android.support.v4.app.NavUtils;
 import android.text.TextUtils;
 import android.view.LayoutInflater;
-import android.view.Menu;
-import android.view.MenuInflater;
 import android.view.MenuItem;
 import android.view.View;
 import android.view.ViewGroup;
@@ -83,6 +82,7 @@
         TextView descTextView = (TextView) view.findViewById(R.id.descriptionTextView);
         TextView distanceTextView = (TextView) view.findViewById(R.id.distanceTextView);
         ImageView imageView = (ImageView) view.findViewById(R.id.imageView);
+        FloatingActionButton mapFab = (FloatingActionButton) view.findViewById(R.id.mapFab);
 
         LatLng location = Utils.getLocation(getActivity());
         String distance = Utils.formatDistanceBetween(location, mAttraction.location);
@@ -102,13 +102,18 @@
                 .placeholder(R.color.lighter_gray)
                 .override(imageSize, imageSize)
                 .into(imageView);
-        return view;
-    }
 
-    @Override
-    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
-        inflater.inflate(R.menu.detail, menu);
-        super.onCreateOptionsMenu(menu, inflater);
+        mapFab.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                Intent intent = new Intent(Intent.ACTION_VIEW);
+                intent.setData(Uri.parse(Constants.MAPS_INTENT_URI +
+                        Uri.encode(mAttraction.name + ", " + mAttraction.city)));
+                startActivity(intent);
+            }
+        });
+
+        return view;
     }
 
     @Override
@@ -139,12 +144,6 @@
 
                 // Otherwise let the system handle navigating "up"
                 return false;
-            case R.id.map:
-                Intent intent = new Intent(Intent.ACTION_VIEW);
-                intent.setData(Uri.parse(Constants.MAPS_INTENT_URI +
-                        Uri.encode(mAttraction.name + ", " + mAttraction.city)));
-                startActivity(intent);
-                return true;
         }
         return super.onOptionsItemSelected(item);
     }
diff --git a/samples/browseable/XYZTouristAttractions/Application/src/com.example.android.xyztouristattractions/ui/ScaleTransition.java b/samples/browseable/XYZTouristAttractions/Application/src/com.example.android.xyztouristattractions/ui/ScaleTransition.java
new file mode 100644
index 0000000..a7e4b2e
--- /dev/null
+++ b/samples/browseable/XYZTouristAttractions/Application/src/com.example.android.xyztouristattractions/ui/ScaleTransition.java
@@ -0,0 +1,46 @@
+package com.example.android.xyztouristattractions.ui;
+
+import android.animation.Animator;
+import android.animation.ObjectAnimator;
+import android.animation.PropertyValuesHolder;
+import android.annotation.TargetApi;
+import android.content.Context;
+import android.os.Build;
+import android.transition.TransitionValues;
+import android.transition.Visibility;
+import android.util.AttributeSet;
+import android.view.View;
+import android.view.ViewGroup;
+
+/**
+ * A simple scale transition class to allow an element to scale in or out.
+ * This is used by the floating action button on the attraction detail screen
+ * when it appears and disappears during the Activity transitions.
+ */
+@TargetApi(Build.VERSION_CODES.LOLLIPOP)
+public class ScaleTransition extends Visibility {
+
+    public ScaleTransition(Context context, AttributeSet attrs) {
+        super(context, attrs);
+    }
+
+    public Animator createAnimation(View view, float startScale, float endScale) {
+        view.setScaleX(startScale);
+        view.setScaleY(startScale);
+        PropertyValuesHolder holderX = PropertyValuesHolder.ofFloat("scaleX", startScale, endScale);
+        PropertyValuesHolder holderY = PropertyValuesHolder.ofFloat("scaleY", startScale, endScale);
+        return ObjectAnimator.ofPropertyValuesHolder(view, holderX, holderY);
+    }
+
+    @Override
+    public Animator onAppear(ViewGroup sceneRoot, View view, TransitionValues startValues,
+                             TransitionValues endValues) {
+        return createAnimation(view, 0, 1);
+    }
+
+    @Override
+    public Animator onDisappear(ViewGroup sceneRoot, View view, TransitionValues startValues,
+                                TransitionValues endValues) {
+        return createAnimation(view, 1, 0);
+    }
+}
\ No newline at end of file
diff --git a/samples/browseable/XYZTouristAttractions/Shared/res/values/colors.xml b/samples/browseable/XYZTouristAttractions/Shared/res/values/colors.xml
index 73c2b6c..2260336 100644
--- a/samples/browseable/XYZTouristAttractions/Shared/res/values/colors.xml
+++ b/samples/browseable/XYZTouristAttractions/Shared/res/values/colors.xml
@@ -20,5 +20,6 @@
     <color name="colorPrimary">#4e6cef</color>
     <color name="colorPrimaryDark">#2a36b1</color>
     <color name="colorAccent">#ff7043</color>
+    <color name="colorFabRipple">#D84315</color>
 
 </resources>
\ No newline at end of file
diff --git a/samples/browseable/XYZTouristAttractions/Wearable/AndroidManifest.xml b/samples/browseable/XYZTouristAttractions/Wearable/AndroidManifest.xml
index 24328b3..80d0c92 100644
--- a/samples/browseable/XYZTouristAttractions/Wearable/AndroidManifest.xml
+++ b/samples/browseable/XYZTouristAttractions/Wearable/AndroidManifest.xml
@@ -22,7 +22,7 @@
 
     <uses-sdk
         android:minSdkVersion="21"
-        android:targetSdkVersion="21" />
+        android:targetSdkVersion="22" />
 
     <application
         android:allowBackup="true"
@@ -32,9 +32,6 @@
 
         <activity
             android:name=".ui.AttractionsActivity"
-            android:exported="true"
-            android:allowEmbedded="true"
-            android:taskAffinity=""
             android:label="@string/app_name" />
 
         <activity
diff --git a/samples/browseable/XYZTouristAttractions/Wearable/src/com.example.android.xyztouristattractions/service/ListenerService.java b/samples/browseable/XYZTouristAttractions/Wearable/src/com.example.android.xyztouristattractions/service/ListenerService.java
index 3908414..d228251 100644
--- a/samples/browseable/XYZTouristAttractions/Wearable/src/com.example.android.xyztouristattractions/service/ListenerService.java
+++ b/samples/browseable/XYZTouristAttractions/Wearable/src/com.example.android.xyztouristattractions/service/ListenerService.java
@@ -30,7 +30,6 @@
 import com.example.android.xyztouristattractions.ui.AttractionsActivity;
 import com.google.android.gms.common.ConnectionResult;
 import com.google.android.gms.common.api.GoogleApiClient;
-import com.google.android.gms.common.data.FreezableUtils;
 import com.google.android.gms.wearable.DataEvent;
 import com.google.android.gms.wearable.DataEventBuffer;
 import com.google.android.gms.wearable.DataMap;
@@ -54,9 +53,7 @@
     public void onDataChanged(DataEventBuffer dataEvents) {
         Log.d(TAG, "onDataChanged: " + dataEvents);
 
-        final List<DataEvent> events = FreezableUtils.freezeIterable(dataEvents);
-
-        for (DataEvent event : events) {
+        for (DataEvent event : dataEvents) {
             if (event.getType() == DataEvent.TYPE_CHANGED
                     && event.getDataItem() != null
                     && Constants.ATTRACTION_PATH.equals(event.getDataItem().getUri().getPath())) {
diff --git a/samples/samples_source.prop_template b/samples/samples_source.prop_template
index 523d6bd..3d4fac5 100644
--- a/samples/samples_source.prop_template
+++ b/samples/samples_source.prop_template
@@ -1,4 +1,4 @@
 Pkg.UserSrc=false
-Pkg.Revision=2
+Pkg.Revision=3
 AndroidVersion.ApiLevel=${PLATFORM_SDK_VERSION}
 AndroidVersion.CodeName=${PLATFORM_VERSION_CODENAME}
diff --git a/sdk/build_tools_source.prop_template b/sdk/build_tools_source.prop_template
index 5d62307..b83af7f 100644
--- a/sdk/build_tools_source.prop_template
+++ b/sdk/build_tools_source.prop_template
@@ -1,3 +1,3 @@
 Pkg.UserSrc=false
-Pkg.Revision=${PLATFORM_SDK_VERSION}.0.0
+Pkg.Revision=${PLATFORM_SDK_VERSION}.0.1