am cd72fc72: Merge "XYZ Tourist Attractions sample - update for wearable support lib 1.2.0" into lmp-docs

* commit 'cd72fc72accc09b45d83117e0d54690153e40f32':
  XYZ Tourist Attractions sample - update for wearable support lib 1.2.0
diff --git a/background/JobScheduler/template-params.xml b/background/JobScheduler/template-params.xml
index a9e06de..2a6197b 100644
--- a/background/JobScheduler/template-params.xml
+++ b/background/JobScheduler/template-params.xml
@@ -23,7 +23,7 @@
     <package>com.example.android.jobscheduler</package>
 
     <!-- change minSdk if needed-->
-    <minSdk>18</minSdk>
+    <minSdk>21</minSdk>
     <compileSdkVersion>21</compileSdkVersion>
 
     <strings>
diff --git a/background/alarms/RepeatingAlarm/template-params.xml b/background/alarms/RepeatingAlarm/template-params.xml
index b013a53..f2d68c5 100644
--- a/background/alarms/RepeatingAlarm/template-params.xml
+++ b/background/alarms/RepeatingAlarm/template-params.xml
@@ -21,7 +21,7 @@
 
 
     <!--TODO: change minSdk if needed-->
-    <minSdk>4</minSdk>
+    <minSdk>11</minSdk>
 
     <strings>
         <intro>
diff --git a/build.gradle b/build.gradle
index 5c72a6f..cdaf043 100644
--- a/build.gradle
+++ b/build.gradle
@@ -97,6 +97,8 @@
 "admin/NfcProvisioning",
 "admin/DeviceOwner",
 "wearable/wear/XYZTouristAttractions",
+"connectivity/bluetooth/BluetoothAdvertisements",
+"wearable/wear/AlwaysOn",
 ]
 
 List<String> taskNames = [
diff --git a/connectivity/bluetooth/BluetoothAdvertisements/Application/.gitignore b/connectivity/bluetooth/BluetoothAdvertisements/Application/.gitignore
new file mode 100644
index 0000000..6eb878d
--- /dev/null
+++ b/connectivity/bluetooth/BluetoothAdvertisements/Application/.gitignore
@@ -0,0 +1,16 @@
+# 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.
+src/template/
+src/common/
+build.gradle
diff --git a/connectivity/bluetooth/BluetoothAdvertisements/Application/proguard-project.txt b/connectivity/bluetooth/BluetoothAdvertisements/Application/proguard-project.txt
new file mode 100644
index 0000000..0d8f171
--- /dev/null
+++ b/connectivity/bluetooth/BluetoothAdvertisements/Application/proguard-project.txt
@@ -0,0 +1,20 @@
+ To enable ProGuard in your project, edit project.properties
+# to define the proguard.config property as described in that file.
+#
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in ${sdk.dir}/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the ProGuard
+# include property in project.properties.
+#
+# For more details, see
+#   http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+#   public *;
+#}
diff --git a/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/AndroidManifest.xml b/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..48084fc
--- /dev/null
+++ b/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/AndroidManifest.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.example.android.bluetoothadvertisements"
+    android:versionCode="1"
+    android:versionName="1.0">
+
+    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
+    <uses-permission android:name="android.permission.BLUETOOTH"/>
+
+    <application android:allowBackup="true"
+        android:label="@string/app_name"
+        android:icon="@drawable/ic_launcher"
+        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>
+    </application>
+
+</manifest>
diff --git a/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/java/com/example/android/bluetoothadvertisements/AdvertiserFragment.java b/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/java/com/example/android/bluetoothadvertisements/AdvertiserFragment.java
new file mode 100644
index 0000000..f8daefb
--- /dev/null
+++ b/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/java/com/example/android/bluetoothadvertisements/AdvertiserFragment.java
@@ -0,0 +1,190 @@
+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.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Switch;
+import android.widget.Toast;
+
+/**
+ * Allows user to start & stop Bluetooth LE Advertising of their device.
+ */
+public class AdvertiserFragment extends Fragment {
+
+    private BluetoothAdapter mBluetoothAdapter;
+
+    private BluetoothLeAdvertiser mBluetoothLeAdvertiser;
+
+    private AdvertiseCallback mAdvertiseCallback;
+
+    private Switch mSwitch;
+
+    /**
+     * Must be called after object creation by MainActivity.
+     *
+     * @param btAdapter the local BluetoothAdapter
+     */
+    public void setBluetoothAdapter(BluetoothAdapter btAdapter) {
+        this.mBluetoothAdapter = btAdapter;
+        mBluetoothLeAdvertiser = mBluetoothAdapter.getBluetoothLeAdvertiser();
+    }
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setRetainInstance(true);
+    }
+
+    @Override
+    public View onCreateView(LayoutInflater inflater, ViewGroup container,
+            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);
+            }
+        });
+
+        return view;
+    }
+
+    @Override
+    public void onStop() {
+        super.onStop();
+
+        if(mAdvertiseCallback != null){
+            stopAdvertising();
+        }
+    }
+
+    /**
+     * Called when switch is toggled - starts or stops advertising.
+     *
+     * @param view is the Switch View object
+     */
+    public void onSwitchClicked(View view) {
+
+        // Is the toggle on?
+        boolean on = ((Switch) view).isChecked();
+
+        if (on) {
+            startAdvertising();
+        } else {
+            stopAdvertising();
+        }
+    }
+
+    /**
+     * Starts BLE Advertising.
+     */
+    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();
+        }
+    }
+
+    /**
+     * Stops BLE Advertising.
+     */
+    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();
+        }
+    }
+
+    /**
+     * 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.
+        }
+    }
+
+}
diff --git a/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/java/com/example/android/bluetoothadvertisements/Constants.java b/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/java/com/example/android/bluetoothadvertisements/Constants.java
new file mode 100644
index 0000000..d3941e2
--- /dev/null
+++ b/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/java/com/example/android/bluetoothadvertisements/Constants.java
@@ -0,0 +1,22 @@
+package com.example.android.bluetoothadvertisements;
+
+import android.os.ParcelUuid;
+
+/**
+ * Constants for use in the Bluetooth Advertisements sample
+ */
+public class Constants {
+
+    /**
+     * UUID identified with this app - set as Service UUID for BLE Advertisements.
+     *
+     * Bluetooth requires a certain format for UUIDs associated with Services.
+     * The official specification can be found here:
+     * {@link https://www.bluetooth.org/en-us/specification/assigned-numbers/service-discovery}
+     */
+    public static final ParcelUuid Service_UUID = ParcelUuid
+            .fromString("0000b81d-0000-1000-8000-00805f9b34fb");
+
+    public static final int REQUEST_ENABLE_BT = 1;
+
+}
diff --git a/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/java/com/example/android/bluetoothadvertisements/MainActivity.java b/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/java/com/example/android/bluetoothadvertisements/MainActivity.java
new file mode 100644
index 0000000..f0044a3
--- /dev/null
+++ b/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/java/com/example/android/bluetoothadvertisements/MainActivity.java
@@ -0,0 +1,130 @@
+/*
+* 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.
+*/
+
+package com.example.android.bluetoothadvertisements;
+
+import android.bluetooth.BluetoothAdapter;
+import android.bluetooth.BluetoothManager;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.v4.app.FragmentActivity;
+import android.support.v4.app.FragmentTransaction;
+import android.widget.TextView;
+import android.widget.Toast;
+
+/**
+ * Setup display fragments and ensure the device supports Bluetooth.
+ */
+public class MainActivity extends FragmentActivity {
+
+    private BluetoothAdapter mBluetoothAdapter;
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_main);
+        setTitle(R.string.activity_main_title);
+
+        if (savedInstanceState == null ) {
+
+            mBluetoothAdapter = ((BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE))
+                    .getAdapter();
+
+            // Is Bluetooth supported on this device?
+            if (mBluetoothAdapter != null) {
+
+                // Is Bluetooth turned on?
+                if (mBluetoothAdapter.isEnabled()) {
+
+                    // Are Bluetooth Advertisements supported on this device?
+                    if (mBluetoothAdapter.isMultipleAdvertisementSupported()) {
+
+                        // Everything is supported and enabled, load the fragments.
+                        setupFragments();
+
+                    } else {
+
+                        // Bluetooth Advertisements are not supported.
+                        showErrorText(R.string.bt_ads_not_supported);
+                    }
+                } else {
+
+                    // Prompt user to turn on Bluetooth (logic continues in onActivityResult()).
+                    Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
+                    startActivityForResult(enableBtIntent, Constants.REQUEST_ENABLE_BT);
+                }
+            } else {
+
+                // Bluetooth is not supported.
+                showErrorText(R.string.bt_not_supported);
+            }
+        }
+    }
+
+    @Override
+    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+        super.onActivityResult(requestCode, resultCode, data);
+        switch (requestCode) {
+            case Constants.REQUEST_ENABLE_BT:
+
+                if (resultCode == RESULT_OK) {
+
+                    // Bluetooth is now Enabled, are Bluetooth Advertisements supported on
+                    // this device?
+                    if (mBluetoothAdapter.isMultipleAdvertisementSupported()) {
+
+                        // Everything is supported and enabled, load the fragments.
+                        setupFragments();
+
+                    } else {
+
+                        // Bluetooth Advertisements are not supported.
+                        showErrorText(R.string.bt_ads_not_supported);
+                    }
+                } else {
+
+                    // User declined to enable Bluetooth, exit the app.
+                    Toast.makeText(this, R.string.bt_not_enabled_leaving,
+                            Toast.LENGTH_SHORT).show();
+                    finish();
+                }
+
+            default:
+                super.onActivityResult(requestCode, resultCode, data);
+        }
+    }
+
+    private void setupFragments() {
+        FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
+
+        ScannerFragment scannerFragment = new ScannerFragment();
+        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();
+    }
+
+    private void showErrorText(int messageId) {
+
+        TextView view = (TextView) findViewById(R.id.error_textview);
+        view.setText(getString(messageId));
+    }
+}
\ No newline at end of file
diff --git a/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/java/com/example/android/bluetoothadvertisements/ScanResultAdapter.java b/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/java/com/example/android/bluetoothadvertisements/ScanResultAdapter.java
new file mode 100644
index 0000000..0f905ea
--- /dev/null
+++ b/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/java/com/example/android/bluetoothadvertisements/ScanResultAdapter.java
@@ -0,0 +1,147 @@
+package com.example.android.bluetoothadvertisements;
+
+import android.bluetooth.le.ScanResult;
+import android.content.Context;
+import android.os.SystemClock;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.BaseAdapter;
+import android.widget.TextView;
+
+import java.util.ArrayList;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Holds and displays {@link ScanResult}s, used by {@link ScannerFragment}.
+ */
+public class ScanResultAdapter extends BaseAdapter {
+
+    private ArrayList<ScanResult> mArrayList;
+
+    private Context mContext;
+
+    private LayoutInflater mInflater;
+
+    ScanResultAdapter(Context context, LayoutInflater inflater) {
+        super();
+        mContext = context;
+        mInflater = inflater;
+        mArrayList = new ArrayList<>();
+    }
+
+    @Override
+    public int getCount() {
+        return mArrayList.size();
+    }
+
+    @Override
+    public Object getItem(int position) {
+        return mArrayList.get(position);
+    }
+
+    @Override
+    public long getItemId(int position) {
+        return mArrayList.get(position).getDevice().getAddress().hashCode();
+    }
+
+    @Override
+    public View getView(int position, View view, ViewGroup parent) {
+
+        // Reuse an old view if we can, otherwise create a new one.
+        if (view == null) {
+            view = mInflater.inflate(R.layout.listitem_scanresult, null);
+        }
+
+        TextView deviceNameView = (TextView) view.findViewById(R.id.device_name);
+        TextView deviceAddressView = (TextView) view.findViewById(R.id.device_address);
+        TextView lastSeenView = (TextView) view.findViewById(R.id.last_seen);
+
+        ScanResult scanResult = mArrayList.get(position);
+
+        deviceNameView.setText(scanResult.getDevice().getName());
+        deviceAddressView.setText(scanResult.getDevice().getAddress());
+        lastSeenView.setText(getTimeSinceString(mContext, scanResult.getTimestampNanos()));
+
+        return view;
+    }
+
+    /**
+     * Search the adapter for an existing device address and return it, otherwise return -1.
+     */
+    private int getPosition(String address) {
+        int position = -1;
+        for (int i = 0; i < mArrayList.size(); i++) {
+            if (mArrayList.get(i).getDevice().getAddress().equals(address)) {
+                position = i;
+                break;
+            }
+        }
+        return position;
+    }
+
+
+    /**
+     * Add a ScanResult item to the adapter if a result from that device isn't already present.
+     * Otherwise updates the existing position with the new ScanResult.
+     */
+    public void add(ScanResult scanResult) {
+
+        int existingPosition = getPosition(scanResult.getDevice().getAddress());
+
+        if (existingPosition >= 0) {
+            // Device is already in list, update its record.
+            mArrayList.set(existingPosition, scanResult);
+        } else {
+            // Add new Device's ScanResult to list.
+            mArrayList.add(scanResult);
+        }
+    }
+
+    /**
+     * Clear out the adapter.
+     */
+    public void clear() {
+        mArrayList.clear();
+    }
+
+    /**
+     * Takes in a number of nanoseconds and returns a human-readable string giving a vague
+     * description of how long ago that was.
+     */
+    public static String getTimeSinceString(Context context, long timeNanoseconds) {
+        String lastSeenText = context.getResources().getString(R.string.last_seen) + " ";
+
+        long timeSince = SystemClock.elapsedRealtimeNanos() - timeNanoseconds;
+        long secondsSince = TimeUnit.SECONDS.convert(timeSince, TimeUnit.NANOSECONDS);
+
+        if (secondsSince < 5) {
+            lastSeenText += context.getResources().getString(R.string.just_now);
+        } else if (secondsSince < 60) {
+            lastSeenText += secondsSince + " " + context.getResources()
+                    .getString(R.string.seconds_ago);
+        } else {
+            long minutesSince = TimeUnit.MINUTES.convert(secondsSince, TimeUnit.SECONDS);
+            if (minutesSince < 60) {
+                if (minutesSince == 1) {
+                    lastSeenText += minutesSince + " " + context.getResources()
+                            .getString(R.string.minute_ago);
+                } else {
+                    lastSeenText += minutesSince + " " + context.getResources()
+                            .getString(R.string.minutes_ago);
+                }
+            } else {
+                long hoursSince = TimeUnit.HOURS.convert(minutesSince, TimeUnit.MINUTES);
+                if (hoursSince == 1) {
+                    lastSeenText += hoursSince + " " + context.getResources()
+                            .getString(R.string.hour_ago);
+                } else {
+                    lastSeenText += hoursSince + " " + context.getResources()
+                            .getString(R.string.hours_ago);
+                }
+            }
+        }
+
+        return lastSeenText;
+    }
+}
diff --git a/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/java/com/example/android/bluetoothadvertisements/ScannerFragment.java b/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/java/com/example/android/bluetoothadvertisements/ScannerFragment.java
new file mode 100644
index 0000000..b9ad4d9
--- /dev/null
+++ b/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/java/com/example/android/bluetoothadvertisements/ScannerFragment.java
@@ -0,0 +1,212 @@
+package com.example.android.bluetoothadvertisements;
+
+import android.bluetooth.BluetoothAdapter;
+import android.bluetooth.le.BluetoothLeScanner;
+import android.bluetooth.le.ScanCallback;
+import android.bluetooth.le.ScanFilter;
+import android.bluetooth.le.ScanResult;
+import android.bluetooth.le.ScanSettings;
+import android.os.Bundle;
+import android.os.Handler;
+import android.support.v4.app.ListFragment;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Toast;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+
+/**
+ * Scans for Bluetooth Low Energy Advertisements matching a filter and displays them to the user.
+ */
+public class ScannerFragment extends ListFragment {
+
+    private static final String TAG = ScannerFragment.class.getSimpleName();
+
+    /**
+     * Stops scanning after 5 seconds.
+     */
+    private static final long SCAN_PERIOD = 5000;
+
+    private BluetoothAdapter mBluetoothAdapter;
+
+    private BluetoothLeScanner mBluetoothLeScanner;
+
+    private ScanCallback mScanCallback;
+
+    private ScanResultAdapter mAdapter;
+
+    private Handler mHandler;
+
+    /**
+     * Must be called after object creation by MainActivity.
+     *
+     * @param btAdapter the local BluetoothAdapter
+     */
+    public void setBluetoothAdapter(BluetoothAdapter btAdapter) {
+        this.mBluetoothAdapter = btAdapter;
+        mBluetoothLeScanner = mBluetoothAdapter.getBluetoothLeScanner();
+    }
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setHasOptionsMenu(true);
+        setRetainInstance(true);
+
+        // Use getActivity().getApplicationContext() instead of just getActivity() because this
+        // object lives in a fragment and needs to be kept separate from the Activity lifecycle.
+        //
+        // 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()));
+        mHandler = new Handler();
+
+    }
+
+    @Override
+    public View onCreateView(LayoutInflater inflater, ViewGroup container,
+                             Bundle savedInstanceState) {
+
+        final View view = super.onCreateView(inflater, container, savedInstanceState);
+
+        setListAdapter(mAdapter);
+
+        return view;
+    }
+
+    @Override
+    public void onViewCreated(View view, Bundle savedInstanceState) {
+        super.onViewCreated(view, savedInstanceState);
+
+        getListView().setDivider(null);
+        getListView().setDividerHeight(0);
+
+        setEmptyText(getString(R.string.empty_list));
+
+        // Trigger refresh on app's 1st load
+        startScanning();
+
+    }
+
+    @Override
+    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
+        super.onCreateOptionsMenu(menu, inflater);
+        inflater.inflate(R.menu.scanner_menu, menu);
+    }
+
+    @Override
+    public boolean onOptionsItemSelected(MenuItem item) {
+
+        switch (item.getItemId()) {
+            case R.id.refresh:
+                startScanning();
+                return true;
+            default:
+                return super.onOptionsItemSelected(item);
+        }
+    }
+
+    /**
+     * Start scanning for BLE Advertisements (& set it up to stop after a set period of time).
+     */
+    public void startScanning() {
+        if (mScanCallback == null) {
+            Log.d(TAG, "Starting Scanning");
+
+            // Will stop the scanning after a set time.
+            mHandler.postDelayed(new Runnable() {
+                @Override
+                public void run() {
+                    stopScanning();
+                }
+            }, SCAN_PERIOD);
+
+            // Kick off a new scan.
+            mScanCallback = new SampleScanCallback();
+            mBluetoothLeScanner.startScan(buildScanFilters(), buildScanSettings(), mScanCallback);
+
+            String toastText = getString(R.string.scan_start_toast) + " "
+                    + TimeUnit.SECONDS.convert(SCAN_PERIOD, TimeUnit.MILLISECONDS) + " "
+                    + getString(R.string.seconds);
+            Toast.makeText(getActivity(), toastText, Toast.LENGTH_LONG).show();
+        } else {
+            Toast.makeText(getActivity(), R.string.already_scanning, Toast.LENGTH_SHORT);
+        }
+    }
+
+    /**
+     * Stop scanning for BLE Advertisements.
+     */
+    public void stopScanning() {
+        Log.d(TAG, "Stopping Scanning");
+
+        // Stop the scan, wipe the callback.
+        mBluetoothLeScanner.stopScan(mScanCallback);
+        mScanCallback = null;
+
+        // Even if no new results, update 'last seen' times.
+        mAdapter.notifyDataSetChanged();
+    }
+
+    /**
+     * Return a List of {@link ScanFilter} objects to filter by Service UUID.
+     */
+    private List<ScanFilter> buildScanFilters() {
+        List<ScanFilter> scanFilters = new ArrayList<>();
+
+        ScanFilter.Builder builder = new ScanFilter.Builder();
+        builder.setServiceUuid(Constants.Service_UUID);
+        scanFilters.add(builder.build());
+
+        return scanFilters;
+    }
+
+    /**
+     * Return a {@link ScanSettings} object set to use low power (to preserve battery life).
+     */
+    private ScanSettings buildScanSettings() {
+        ScanSettings.Builder builder = new ScanSettings.Builder();
+        builder.setScanMode(ScanSettings.SCAN_MODE_LOW_POWER);
+        return builder.build();
+    }
+
+    /**
+     * Custom ScanCallback object - adds to adapter on success, displays error on failure.
+     */
+    private class SampleScanCallback extends ScanCallback {
+
+        @Override
+        public void onBatchScanResults(List<ScanResult> results) {
+            super.onBatchScanResults(results);
+
+            for (ScanResult result : results) {
+                mAdapter.add(result);
+            }
+            mAdapter.notifyDataSetChanged();
+        }
+
+        @Override
+        public void onScanResult(int callbackType, ScanResult result) {
+            super.onScanResult(callbackType, result);
+
+            mAdapter.add(result);
+            mAdapter.notifyDataSetChanged();
+        }
+
+        @Override
+        public void onScanFailed(int errorCode) {
+            super.onScanFailed(errorCode);
+            Toast.makeText(getActivity(), "Scan failed with error: " + errorCode, Toast.LENGTH_LONG)
+                    .show();
+        }
+    }
+}
diff --git a/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/res/drawable-hdpi/ic_action_refresh.png b/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/res/drawable-hdpi/ic_action_refresh.png
new file mode 100644
index 0000000..dae2790
--- /dev/null
+++ b/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/res/drawable-hdpi/ic_action_refresh.png
Binary files differ
diff --git a/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/res/drawable-hdpi/ic_launcher.png b/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/res/drawable-hdpi/ic_launcher.png
new file mode 100644
index 0000000..b1efaf4
--- /dev/null
+++ b/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/res/drawable-hdpi/ic_launcher.png
Binary files differ
diff --git a/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/res/drawable-mdpi/ic_action_refresh.png b/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/res/drawable-mdpi/ic_action_refresh.png
new file mode 100644
index 0000000..94ab6f4
--- /dev/null
+++ b/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/res/drawable-mdpi/ic_action_refresh.png
Binary files differ
diff --git a/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/res/drawable-mdpi/ic_launcher.png b/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/res/drawable-mdpi/ic_launcher.png
new file mode 100644
index 0000000..f5f9244
--- /dev/null
+++ b/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/res/drawable-mdpi/ic_launcher.png
Binary files differ
diff --git a/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/res/drawable-xhdpi/ic_action_refresh.png b/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/res/drawable-xhdpi/ic_action_refresh.png
new file mode 100644
index 0000000..ab4ab9d
--- /dev/null
+++ b/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/res/drawable-xhdpi/ic_action_refresh.png
Binary files differ
diff --git a/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/res/drawable-xhdpi/ic_launcher.png b/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/res/drawable-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..5d07b3f
--- /dev/null
+++ b/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/res/drawable-xhdpi/ic_launcher.png
Binary files differ
diff --git a/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/res/drawable-xxhdpi/ic_action_refresh.png b/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/res/drawable-xxhdpi/ic_action_refresh.png
new file mode 100644
index 0000000..44ee117
--- /dev/null
+++ b/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/res/drawable-xxhdpi/ic_action_refresh.png
Binary files differ
diff --git a/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/res/drawable-xxhdpi/ic_launcher.png b/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/res/drawable-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..6ef21e1
--- /dev/null
+++ b/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/res/drawable-xxhdpi/ic_launcher.png
Binary files differ
diff --git a/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/res/layout/activity_main.xml b/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/res/layout/activity_main.xml
new file mode 100755
index 0000000..817cccc
--- /dev/null
+++ b/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/res/layout/activity_main.xml
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  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.
+  -->
+<LinearLayout
+        xmlns:android="http://schemas.android.com/apk/res/android"
+        android:orientation="vertical"
+        android:layout_width="fill_parent"
+        android:layout_height="fill_parent"
+        android:id="@+id/sample_main_layout">
+
+    <FrameLayout
+        android:id="@+id/scanner_fragment_container"
+        android:layout_weight="1"
+        android:layout_width="match_parent"
+        android:layout_height="0px" >
+
+            <TextView
+                android:id="@+id/error_textview"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:freezesText="true" />
+
+        </FrameLayout>
+
+    <FrameLayout
+        android:id="@+id/advertiser_fragment_container"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content" />
+
+    <!--<fragment-->
+        <!--android:name="com.example.android.bluetoothadvertisements.ScannerFragment"-->
+        <!--android:id="@+id/scanner_fragment"-->
+        <!--android:layout_width="match_parent"-->
+        <!--android:layout_height="wrap_content" />-->
+
+    <!--<fragment-->
+        <!--android:name="com.example.android.bluetoothadvertisements.AdvertiserFragment"-->
+        <!--android:id="@+id/advertiser_fragment"-->
+        <!--android:layout_width="match_parent"-->
+        <!--android:layout_height="wrap_content" />-->
+
+</LinearLayout>
diff --git a/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/res/layout/fragment_advertiser.xml b/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/res/layout/fragment_advertiser.xml
new file mode 100644
index 0000000..4031b8d
--- /dev/null
+++ b/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/res/layout/fragment_advertiser.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 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.
+-->
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    tools:context="com.example.android.bluetoothadvertisements.AdvertiserFragment">
+
+    <!-- Horizontal Divider -->
+    <View
+        android:layout_width="250dp"
+        android:layout_height="1dp"
+        android:layout_centerHorizontal="true"
+        android:layout_alignParentTop="true"
+        android:background="@android:color/darker_gray"/>
+
+    <LinearLayout
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:orientation="horizontal"
+        android:layout_centerInParent="true"
+        android:paddingTop="20dp"
+        android:paddingBottom="20dp" >
+
+        <TextView
+            android:text="@string/broadcast_device"
+            android:layout_width="wrap_content"
+            android:layout_height="match_parent"
+            android:minWidth="100dp"
+            android:padding="5dp"/>
+
+        <Switch
+            android:id="@+id/advertise_switch"
+            android:layout_width="wrap_content"
+            android:layout_height="match_parent"
+            android:switchMinWidth="80dp" />
+
+    </LinearLayout>
+
+</RelativeLayout>
diff --git a/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/res/layout/listitem_scanresult.xml b/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/res/layout/listitem_scanresult.xml
new file mode 100644
index 0000000..ff5956f
--- /dev/null
+++ b/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/res/layout/listitem_scanresult.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 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.
+-->
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    >
+
+<LinearLayout
+              android:orientation="vertical"
+              android:layout_width="match_parent"
+              android:layout_height="wrap_content"
+              android:paddingTop="20dp"
+            android:paddingLeft="100dp"
+            android:paddingRight="100dp">
+    <TextView android:id="@+id/device_name"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:textSize="16dp"/>
+
+    <TextView android:id="@+id/device_address"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:textSize="12dp"/>
+    <TextView android:id="@+id/last_seen"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:textSize="12dp"/>
+</LinearLayout>
+</RelativeLayout>
\ No newline at end of file
diff --git a/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/res/menu-v21/scanner_menu.xml b/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/res/menu-v21/scanner_menu.xml
new file mode 100644
index 0000000..8dda284
--- /dev/null
+++ b/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/res/menu-v21/scanner_menu.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:id="@+id/refresh"
+        android:title="@string/refresh"
+        android:showAsAction="always"
+        android:icon="@drawable/ic_action_refresh"
+         />
+</menu>
\ No newline at end of file
diff --git a/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/res/values/strings.xml b/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/res/values/strings.xml
new file mode 100644
index 0000000..197178d
--- /dev/null
+++ b/connectivity/bluetooth/BluetoothAdvertisements/Application/src/main/res/values/strings.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+    <string name="bt_not_enabled_leaving">User declined to enable Bluetooth, exiting Bluetooth Advertisements.</string>
+    <string name="activity_main_title">Nearby Devices</string>
+    <string name="broadcast_device">Broadcast Device</string>
+
+    <string name="bt_not_supported">Bluetooth is not supported on this device.</string>
+    <string name="bt_ads_not_supported">Bluetooth Advertisements are not supported on this device.</string>
+
+    <string name="refresh">Refresh</string>
+    <string name="start_error_prefix">Start Advertising failed: </string>
+    <string name="start_error_already_started">already started.</string>
+    <string name="start_error_too_large">data packet exceeded 31 Byte limit.</string>
+    <string name="start_error_unsupported">not supported on this device.</string>
+    <string name="start_error_internal">internal error.</string>
+    <string name="start_error_too_many">too many advertisers.</string>
+    <string name="bt_null">Error: Bluetooth object null</string>
+    <string name="last_seen">Last Seen:</string>
+    <string name="just_now">just now</string>
+    <string name="minute_ago">minute ago</string>
+    <string name="hour_ago">hour ago</string>
+    <string name="seconds_ago">seconds ago</string>
+    <string name="minutes_ago">minutes ago</string>
+    <string name="hours_ago">hours ago</string>
+    <string name="empty_list">No devices found - refresh to try again.</string>
+    <string name="seconds">seconds.</string>
+    <string name="scan_start_toast">Scanning for</string>
+    <string name="already_scanning">Scanning already started.</string>
+
+</resources>
\ No newline at end of file
diff --git a/connectivity/bluetooth/BluetoothAdvertisements/build.gradle b/connectivity/bluetooth/BluetoothAdvertisements/build.gradle
new file mode 100644
index 0000000..18f393f
--- /dev/null
+++ b/connectivity/bluetooth/BluetoothAdvertisements/build.gradle
@@ -0,0 +1,11 @@
+
+// BEGIN_EXCLUDE
+import com.example.android.samples.build.SampleGenPlugin
+apply plugin: SampleGenPlugin
+
+samplegen {
+  pathToBuild "../../../../../build"
+  pathToSamplesCommon "../../../common"
+}
+apply from: "../../../../../build/build.gradle"
+// END_EXCLUDE
diff --git a/connectivity/bluetooth/BluetoothAdvertisements/buildSrc/build.gradle b/connectivity/bluetooth/BluetoothAdvertisements/buildSrc/build.gradle
new file mode 100644
index 0000000..7cebf71
--- /dev/null
+++ b/connectivity/bluetooth/BluetoothAdvertisements/buildSrc/build.gradle
@@ -0,0 +1,15 @@
+repositories {
+    mavenCentral()
+}
+dependencies {
+    compile 'org.freemarker:freemarker:2.3.20'
+}
+
+sourceSets {
+    main {
+        groovy {
+            srcDir new File(rootDir, "../../../../../../build/buildSrc/src/main/groovy")
+        }
+    }
+}
+
diff --git a/connectivity/bluetooth/BluetoothAdvertisements/gradle/wrapper/gradle-wrapper.jar b/connectivity/bluetooth/BluetoothAdvertisements/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..8c0fb64
--- /dev/null
+++ b/connectivity/bluetooth/BluetoothAdvertisements/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/connectivity/bluetooth/BluetoothAdvertisements/gradle/wrapper/gradle-wrapper.properties b/connectivity/bluetooth/BluetoothAdvertisements/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..8712eac
--- /dev/null
+++ b/connectivity/bluetooth/BluetoothAdvertisements/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Mon Mar 02 15:22:07 PST 2015
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
diff --git a/connectivity/bluetooth/BluetoothAdvertisements/gradlew b/connectivity/bluetooth/BluetoothAdvertisements/gradlew
new file mode 100755
index 0000000..91a7e26
--- /dev/null
+++ b/connectivity/bluetooth/BluetoothAdvertisements/gradlew
@@ -0,0 +1,164 @@
+#!/usr/bin/env bash
+
+##############################################################################
+##
+##  Gradle start up script for UN*X
+##
+##############################################################################
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+    echo "$*"
+}
+
+die ( ) {
+    echo
+    echo "$*"
+    echo
+    exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+case "`uname`" in
+  CYGWIN* )
+    cygwin=true
+    ;;
+  Darwin* )
+    darwin=true
+    ;;
+  MINGW* )
+    msys=true
+    ;;
+esac
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched.
+if $cygwin ; then
+    [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+fi
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+    ls=`ls -ld "$PRG"`
+    link=`expr "$ls" : '.*-> \(.*\)$'`
+    if expr "$link" : '/.*' > /dev/null; then
+        PRG="$link"
+    else
+        PRG=`dirname "$PRG"`"/$link"
+    fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >&-
+APP_HOME="`pwd -P`"
+cd "$SAVED" >&-
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+        # IBM's JDK on AIX uses strange locations for the executables
+        JAVACMD="$JAVA_HOME/jre/sh/java"
+    else
+        JAVACMD="$JAVA_HOME/bin/java"
+    fi
+    if [ ! -x "$JAVACMD" ] ; then
+        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+    fi
+else
+    JAVACMD="java"
+    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+    MAX_FD_LIMIT=`ulimit -H -n`
+    if [ $? -eq 0 ] ; then
+        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+            MAX_FD="$MAX_FD_LIMIT"
+        fi
+        ulimit -n $MAX_FD
+        if [ $? -ne 0 ] ; then
+            warn "Could not set maximum file descriptor limit: $MAX_FD"
+        fi
+    else
+        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+    fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+    APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+
+    # We build the pattern for arguments to be converted via cygpath
+    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+    SEP=""
+    for dir in $ROOTDIRSRAW ; do
+        ROOTDIRS="$ROOTDIRS$SEP$dir"
+        SEP="|"
+    done
+    OURCYGPATTERN="(^($ROOTDIRS))"
+    # Add a user-defined pattern to the cygpath arguments
+    if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+    fi
+    # Now convert the arguments - kludge to limit ourselves to /bin/sh
+    i=0
+    for arg in "$@" ; do
+        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option
+
+        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
+            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+        else
+            eval `echo args$i`="\"$arg\""
+        fi
+        i=$((i+1))
+    done
+    case $i in
+        (0) set -- ;;
+        (1) set -- "$args0" ;;
+        (2) set -- "$args0" "$args1" ;;
+        (3) set -- "$args0" "$args1" "$args2" ;;
+        (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+        (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+        (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+        (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+        (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+        (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+    esac
+fi
+
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+    JVM_OPTS=("$@")
+}
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/connectivity/bluetooth/BluetoothAdvertisements/gradlew.bat b/connectivity/bluetooth/BluetoothAdvertisements/gradlew.bat
new file mode 100644
index 0000000..aec9973
--- /dev/null
+++ b/connectivity/bluetooth/BluetoothAdvertisements/gradlew.bat
@@ -0,0 +1,90 @@
+@if "%DEBUG%" == "" @echo off

+@rem ##########################################################################

+@rem

+@rem  Gradle startup script for Windows

+@rem

+@rem ##########################################################################

+

+@rem Set local scope for the variables with windows NT shell

+if "%OS%"=="Windows_NT" setlocal

+

+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.

+set DEFAULT_JVM_OPTS=

+

+set DIRNAME=%~dp0

+if "%DIRNAME%" == "" set DIRNAME=.

+set APP_BASE_NAME=%~n0

+set APP_HOME=%DIRNAME%

+

+@rem Find java.exe

+if defined JAVA_HOME goto findJavaFromJavaHome

+

+set JAVA_EXE=java.exe

+%JAVA_EXE% -version >NUL 2>&1

+if "%ERRORLEVEL%" == "0" goto init

+

+echo.

+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.

+echo.

+echo Please set the JAVA_HOME variable in your environment to match the

+echo location of your Java installation.

+

+goto fail

+

+:findJavaFromJavaHome

+set JAVA_HOME=%JAVA_HOME:"=%

+set JAVA_EXE=%JAVA_HOME%/bin/java.exe

+

+if exist "%JAVA_EXE%" goto init

+

+echo.

+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%

+echo.

+echo Please set the JAVA_HOME variable in your environment to match the

+echo location of your Java installation.

+

+goto fail

+

+:init

+@rem Get command-line arguments, handling Windowz variants

+

+if not "%OS%" == "Windows_NT" goto win9xME_args

+if "%@eval[2+2]" == "4" goto 4NT_args

+

+:win9xME_args

+@rem Slurp the command line arguments.

+set CMD_LINE_ARGS=

+set _SKIP=2

+

+:win9xME_args_slurp

+if "x%~1" == "x" goto execute

+

+set CMD_LINE_ARGS=%*

+goto execute

+

+:4NT_args

+@rem Get arguments from the 4NT Shell from JP Software

+set CMD_LINE_ARGS=%$

+

+:execute

+@rem Setup the command line

+

+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

+

+@rem Execute Gradle

+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%

+

+:end

+@rem End local scope for the variables with windows NT shell

+if "%ERRORLEVEL%"=="0" goto mainEnd

+

+:fail

+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of

+rem the _cmd.exe /c_ return code!

+if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1

+exit /b 1

+

+:mainEnd

+if "%OS%"=="Windows_NT" endlocal

+

+:omega

diff --git a/connectivity/bluetooth/BluetoothAdvertisements/screenshots/1-main.png b/connectivity/bluetooth/BluetoothAdvertisements/screenshots/1-main.png
new file mode 100644
index 0000000..0c537fa
--- /dev/null
+++ b/connectivity/bluetooth/BluetoothAdvertisements/screenshots/1-main.png
Binary files differ
diff --git a/connectivity/bluetooth/BluetoothAdvertisements/screenshots/icon-web.png b/connectivity/bluetooth/BluetoothAdvertisements/screenshots/icon-web.png
new file mode 100644
index 0000000..0a6d413
--- /dev/null
+++ b/connectivity/bluetooth/BluetoothAdvertisements/screenshots/icon-web.png
Binary files differ
diff --git a/connectivity/bluetooth/BluetoothAdvertisements/settings.gradle b/connectivity/bluetooth/BluetoothAdvertisements/settings.gradle
new file mode 100644
index 0000000..9464a35
--- /dev/null
+++ b/connectivity/bluetooth/BluetoothAdvertisements/settings.gradle
@@ -0,0 +1 @@
+include 'Application'
diff --git a/connectivity/bluetooth/BluetoothAdvertisements/template-params.xml b/connectivity/bluetooth/BluetoothAdvertisements/template-params.xml
new file mode 100644
index 0000000..4bd4f2a
--- /dev/null
+++ b/connectivity/bluetooth/BluetoothAdvertisements/template-params.xml
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<sample>
+    <name>BluetoothAdvertisements</name>
+    <group>Connectivity</group>
+    <package>com.example.android.bluetoothadvertisements</package>
+
+    <minSdk>21</minSdk>
+
+
+    <strings>
+        <intro>
+<![CDATA[
+This samples demonstrates how to use the Bluetooth Low Power Advertisements API
+with a single device acting as both scanner and advertiser.
+]]>
+        </intro>
+    </strings>
+
+    <colors>
+        <color>
+            <name>colorPrimary</name>
+            <hexval>#434AB3</hexval>
+        </color>
+        <color>
+            <name>colorPrimaryDark</name>
+            <hexval>#34379D</hexval>
+        </color>
+        <color>
+            <name>textColorPrimary</name>
+            <hexval>#FFFFFF</hexval>
+        </color>
+    </colors>
+
+    <template src="base" />
+
+
+    <metadata>
+        <status>DRAFT</status>
+        <categories>Connectivity</categories>
+        <technologies>Android</technologies>
+        <languages>Java</languages>
+        <solutions>Mobile</solutions>
+        <level>ADVANCED</level>
+        <icon>screenshots/icon-web.png</icon>
+        <screenshots>
+            <img>screenshots/1-main.png</img>
+        </screenshots>
+        <api_refs>
+            <android>android.bluetooth.le.BluetoothLeAdvertiser</android>
+            <android>android.bluetooth.le.BluetoothLeScanner</android>
+        </api_refs>
+
+        <description>
+<![CDATA[
+Sample demonstrating how to advertise small amounts of data using the Bluetooth
+Low Energy API. Also demonstrates how to scan for those Advertisements. (requires
+2 devices to see full operation)
+]]>
+        </description>
+
+        <intro>
+<![CDATA[
+This sample demonstrates use of the Bluetooth Low Energy (BLE) [Advertisement][1] and [Scanning][2] APIs.
+The functionality is split into two fragments - one for Advertising, one for Scanning.
+
+ScannerFragment activates BLE Scanning for 5 seconds and displays a list of found devices which are advertising
+using this sample. It shows the device type, Bluetooth address, and when it was last seen. User can
+refresh to scan again and update the list.
+
+AdvertiserFragment allows the user to toggle BLE Advertising of that device. It broadcasts basic
+information about the device along with a UUID specific to this app so the ScannerFragment on other
+devices can filter by it.
+
+Note: A device cannot detect its own BLE advertisements. You will need two devices to see this
+sample in action.
+
+[1]:https://developer.android.com/reference/android/bluetooth/le/BluetoothLeAdvertiser.html
+[2]:https://developer.android.com/reference/android/bluetooth/le/BluetoothLeScanner.html
+]]>
+        </intro>
+    </metadata>
+</sample>
diff --git a/media/MediaRecorder/template-params.xml b/media/MediaRecorder/template-params.xml
index fa4a165..a057637 100644
--- a/media/MediaRecorder/template-params.xml
+++ b/media/MediaRecorder/template-params.xml
@@ -18,7 +18,7 @@
     <name>MediaRecorder</name>
     <group>Media</group>
     <package>com.example.android.mediarecorder</package>
-    <minSdk>14</minSdk>
+    <minSdk>16</minSdk>
     <strings>
         <intro>
 <![CDATA[
diff --git a/renderScript/BasicRenderScript/template-params.xml b/renderScript/BasicRenderScript/template-params.xml
index d0d3be2..9f0c558 100644
--- a/renderScript/BasicRenderScript/template-params.xml
+++ b/renderScript/BasicRenderScript/template-params.xml
@@ -23,7 +23,7 @@
     <package>com.example.android.basicrenderscript</package>
 
     <!-- change minSdk if needed-->
-    <minSdk>8</minSdk>
+    <minSdk>16</minSdk>
 
     <dependency_external>'renderscript-v8.jar'</dependency_external>
 
diff --git a/renderScript/RenderScriptIntrinsic/template-params.xml b/renderScript/RenderScriptIntrinsic/template-params.xml
index 8b80bb2..a2a9370 100644
--- a/renderScript/RenderScriptIntrinsic/template-params.xml
+++ b/renderScript/RenderScriptIntrinsic/template-params.xml
@@ -21,7 +21,7 @@
     <package>com.example.android.renderscriptintrinsic</package>
 
     <!-- change minSdk if needed-->
-    <minSdk>8</minSdk>
+    <minSdk>13</minSdk>
 
     <dependency_external>'renderscript-v8.jar'</dependency_external>
 
diff --git a/ui/actionbarcompat/ActionBarCompat-ListViewModalSelect/template-params.xml b/ui/actionbarcompat/ActionBarCompat-ListViewModalSelect/template-params.xml
index 03f6877..3c7e83a 100644
--- a/ui/actionbarcompat/ActionBarCompat-ListViewModalSelect/template-params.xml
+++ b/ui/actionbarcompat/ActionBarCompat-ListViewModalSelect/template-params.xml
@@ -25,7 +25,7 @@
     <dependency>com.android.support:appcompat-v7:21.0.2</dependency>
 
     <!-- change minSdk if needed-->
-    <minSdk>7</minSdk>
+    <minSdk>8</minSdk>
 
     <strings>
         <intro>
diff --git a/ui/views/NavigationDrawer/template-params.xml b/ui/views/NavigationDrawer/template-params.xml
index af92a68..559f32e 100644
--- a/ui/views/NavigationDrawer/template-params.xml
+++ b/ui/views/NavigationDrawer/template-params.xml
@@ -25,7 +25,7 @@
     <auto_add_support_lib>false</auto_add_support_lib>
 
     <!-- change minSdk if needed-->
-    <minSdk>14</minSdk>
+    <minSdk>21</minSdk>
     <compileSdkVersion>21</compileSdkVersion>
 
 
diff --git a/ui/views/SlidingTabs/SlidingTabsBasic/template-params.xml b/ui/views/SlidingTabs/SlidingTabsBasic/template-params.xml
index 7d6c97f..fe39dab 100644
--- a/ui/views/SlidingTabs/SlidingTabsBasic/template-params.xml
+++ b/ui/views/SlidingTabs/SlidingTabsBasic/template-params.xml
@@ -23,7 +23,7 @@
     <package>com.example.android.slidingtabsbasic</package>
 
     <!-- change minSdk if needed-->
-    <minSdk>4</minSdk>
+    <minSdk>14</minSdk>
 
 
     <strings>
diff --git a/ui/views/SlidingTabs/SlidingTabsColors/template-params.xml b/ui/views/SlidingTabs/SlidingTabsColors/template-params.xml
index ecdad8c..752927b 100644
--- a/ui/views/SlidingTabs/SlidingTabsColors/template-params.xml
+++ b/ui/views/SlidingTabs/SlidingTabsColors/template-params.xml
@@ -24,7 +24,7 @@
 
 
     <!-- change minSdk if needed-->
-    <minSdk>4</minSdk>
+    <minSdk>14</minSdk>
 
 
     <strings>
diff --git a/ui/views/SwipeRefreshLayout/SwipeRefreshLayoutBasic/template-params.xml b/ui/views/SwipeRefreshLayout/SwipeRefreshLayoutBasic/template-params.xml
index 0b99bcc..ddce9d1 100644
--- a/ui/views/SwipeRefreshLayout/SwipeRefreshLayoutBasic/template-params.xml
+++ b/ui/views/SwipeRefreshLayout/SwipeRefreshLayoutBasic/template-params.xml
@@ -23,7 +23,7 @@
     <package>com.example.android.swiperefreshlayoutbasic</package>
 
     <!-- change minSdk if needed-->
-    <minSdk>10</minSdk>
+    <minSdk>14</minSdk>
 
     <strings>
         <intro>
diff --git a/ui/views/SwipeRefreshLayout/SwipeRefreshListFragment/template-params.xml b/ui/views/SwipeRefreshLayout/SwipeRefreshListFragment/template-params.xml
index 4210182..13230a5 100644
--- a/ui/views/SwipeRefreshLayout/SwipeRefreshListFragment/template-params.xml
+++ b/ui/views/SwipeRefreshLayout/SwipeRefreshListFragment/template-params.xml
@@ -21,7 +21,7 @@
     <name>SwipeRefreshListFragment</name>
     <group>UI</group>
     <package>com.example.android.swiperefreshlistfragment</package>
-    <minSdk>10</minSdk>
+    <minSdk>14</minSdk>
     <strings>
         <intro>
             <![CDATA[
diff --git a/ui/views/SwipeRefreshLayout/SwipeRefreshMultipleViews/template-params.xml b/ui/views/SwipeRefreshLayout/SwipeRefreshMultipleViews/template-params.xml
index bb0054b..ad1ad5e 100644
--- a/ui/views/SwipeRefreshLayout/SwipeRefreshMultipleViews/template-params.xml
+++ b/ui/views/SwipeRefreshLayout/SwipeRefreshMultipleViews/template-params.xml
@@ -23,7 +23,7 @@
     <package>com.example.android.swiperefreshmultipleviews</package>
 
     <!-- change minSdk if needed-->
-    <minSdk>10</minSdk>
+    <minSdk>14</minSdk>
     <strings>
         <intro>
             <![CDATA[
diff --git a/ui/window/ImmersiveMode/template-params.xml b/ui/window/ImmersiveMode/template-params.xml
index 8959099..da1e511 100644
--- a/ui/window/ImmersiveMode/template-params.xml
+++ b/ui/window/ImmersiveMode/template-params.xml
@@ -20,7 +20,7 @@
     <package>com.example.android.immersivemode</package>
     
     <!--TODO: change minSdk if needed-->
-    <minSdk>4</minSdk>
+    <minSdk>11</minSdk>
 
 
     <strings>
diff --git a/wearable/wear/AlwaysOn/Wearable/src/main/AndroidManifest.xml b/wearable/wear/AlwaysOn/Wearable/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..12c4b03
--- /dev/null
+++ b/wearable/wear/AlwaysOn/Wearable/src/main/AndroidManifest.xml
@@ -0,0 +1,51 @@
+<?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.
+-->
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+          package="com.example.android.wearable.wear.alwayson">
+
+    <uses-sdk android:minSdkVersion="20" android:targetSdkVersion="22" />
+
+    <uses-permission android:name="android.permission.WAKE_LOCK" />
+    <uses-permission android:name="com.android.alarm.permission.SET_ALARM"/>
+
+    <uses-feature android:name="android.hardware.type.watch" />
+
+    <application
+        android:allowBackup="false"
+        android:label="@string/app_name">
+
+        <!--If you want your app to run on pre-22, then set required to false -->
+        <uses-library android:name="com.google.android.wearable" android:required="false" />
+
+        <!--
+            To update the screen more than once per minute in ambient mode, developers should set
+            the launch mode for the activity to single instance. Otherwise, the AlarmManager launch
+            intent will open a new activity every time the Alarm is triggered rather than reusing
+            the same (already active) Activity.
+        -->
+        <activity android:name="com.example.android.wearable.wear.alwayson.MainActivity"
+            android:label="@string/app_name"
+            android:launchMode="singleInstance"
+            android:configChanges="orientation|keyboardHidden"
+            android:exported="true">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+
+    </application>
+</manifest>
diff --git a/wearable/wear/AlwaysOn/Wearable/src/main/java/com/example/android/wearable/wear/alwayson/MainActivity.java b/wearable/wear/AlwaysOn/Wearable/src/main/java/com/example/android/wearable/wear/alwayson/MainActivity.java
new file mode 100644
index 0000000..3673545
--- /dev/null
+++ b/wearable/wear/AlwaysOn/Wearable/src/main/java/com/example/android/wearable/wear/alwayson/MainActivity.java
@@ -0,0 +1,336 @@
+/*
+ * Copyright (C) 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.
+ */
+package com.example.android.wearable.wear.alwayson;
+
+import android.app.AlarmManager;
+import android.app.PendingIntent;
+import android.content.Context;
+import android.content.Intent;
+import android.graphics.Color;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.support.wearable.activity.WearableActivity;
+import android.support.wearable.view.WatchViewStub;
+import android.util.Log;
+import android.widget.TextView;
+
+import java.lang.ref.WeakReference;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Demonstrates support for Ambient screens by extending WearableActivity and overriding
+ * onEnterAmbient, onUpdateAmbient, and onExitAmbient.
+ *
+ * There are two modes (Active and Ambient). To trigger future updates (data/screen), we use a
+ * custom Handler for the "Active" mode and an Alarm for the "Ambient" mode.
+ *
+ * Why don't we use just one? Handlers are generally less battery intensive and can be triggered
+ * every second. However, they can not wake up the processor (common in Ambient mode).
+ *
+ * Alarms can wake up the processor (what we need for Ambient), but they struggle with quick updates
+ * (less than one second) and are much less efficient compared to Handlers.
+ *
+ * Therefore, we use Handlers for "Active" mode (can trigger every second and are better on the
+ * battery), and we use Alarms for "Ambient" mode (only need to update once every 20 seconds and
+ * they can wake up a sleeping processor).
+ *
+ * Again, the Activity waits 20 seconds between doing any processing (getting data, updating screen
+ * etc.) while in ambient mode to conserving battery life (processor allowed to sleep). If you can
+ * hold off on updates for a full minute, you can throw away all the Alarm code and just use
+ * onUpdateAmbient() to save even more battery life.
+ *
+ * As always, you will still want to apply the performance guidelines outlined in the Watch Faces
+ * documention to your app.
+ *
+ * Finally, in ambient mode, this Activity follows the same best practices outlined in the
+ * Watch Faces API documentation, e.g., keep most pixels black, avoid large blocks of white pixels,
+ * use only black and white, and disable anti-aliasing.
+ *
+ */
+public class MainActivity extends WearableActivity {
+
+    private static final String TAG = "MainActivity";
+
+    /** Custom 'what' for Message sent to Handler. */
+    private static final int MSG_UPDATE_SCREEN = 0;
+
+    /** Milliseconds between updates based on state. */
+    private static final long ACTIVE_INTERVAL_MS = TimeUnit.SECONDS.toMillis(1);
+    private static final long AMBIENT_INTERVAL_MS = TimeUnit.SECONDS.toMillis(20);
+
+    /** Tracks latest ambient details, such as burnin offsets, etc. */
+    private Bundle mAmbientDetails;
+
+    private TextView mTimeTextView;
+    private TextView mTimeStampTextView;
+    private TextView mStateTextView;
+    private TextView mUpdateRateTextView;
+    private TextView mDrawCountTextView;
+
+    private final SimpleDateFormat sDateFormat =
+            new SimpleDateFormat("HH:mm:ss", Locale.US);
+
+    private volatile int mDrawCount = 0;
+
+
+    /**
+     * Since the handler (used in active mode) can't wake up the processor when the device is in
+     * ambient mode and undocked, we use an Alarm to cover ambient mode updates when we need them
+     * more frequently than every minute. Remember, if getting updates once a minute in ambient
+     * mode is enough, you can do away with the Alarm code and just rely on the onUpdateAmbient()
+     * callback.
+     */
+    private AlarmManager mAmbientStateAlarmManager;
+    private PendingIntent mAmbientStatePendingIntent;
+
+    /**
+     * This custom handler is used for updates in "Active" mode. We use a separate static class to
+     * help us avoid memory leaks.
+     */
+    private final Handler mActiveModeUpdateHandler = new UpdateHandler(this);
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        Log.d(TAG, "onCreate()");
+        super.onCreate(savedInstanceState);
+
+        setContentView(R.layout.activity_main);
+
+        setAmbientEnabled();
+
+        mAmbientStateAlarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
+        Intent ambientStateIntent = new Intent(getApplicationContext(), MainActivity.class);
+
+        mAmbientStatePendingIntent = PendingIntent.getActivity(
+                getApplicationContext(),
+                0 /* requestCode */,
+                ambientStateIntent,
+                PendingIntent.FLAG_UPDATE_CURRENT);
+
+
+        /** Determines whether watch is round or square and applies proper view. **/
+        final WatchViewStub stub = (WatchViewStub) findViewById(R.id.watch_view_stub);
+        stub.setOnLayoutInflatedListener(new WatchViewStub.OnLayoutInflatedListener() {
+            @Override
+            public void onLayoutInflated(WatchViewStub stub) {
+
+                mTimeTextView = (TextView) stub.findViewById(R.id.time);
+                mTimeStampTextView = (TextView) stub.findViewById(R.id.time_stamp);
+                mStateTextView = (TextView) stub.findViewById(R.id.state);
+                mUpdateRateTextView = (TextView) stub.findViewById(R.id.update_rate);
+                mDrawCountTextView = (TextView) stub.findViewById(R.id.draw_count);
+
+                refreshDisplayAndSetNextUpdate();
+            }
+        });
+    }
+
+    /**
+     * This is mostly triggered by the Alarms we set in Ambient mode and informs us we need to
+     * update the screen (and process any data).
+     */
+    @Override
+    public void onNewIntent(Intent intent) {
+        Log.d(TAG, "onNewIntent(): " + intent);
+        super.onNewIntent(intent);
+
+        setIntent(intent);
+
+        refreshDisplayAndSetNextUpdate();
+    }
+
+    @Override
+    public void onDestroy() {
+        Log.d(TAG, "onDestroy()");
+
+        mActiveModeUpdateHandler.removeMessages(MSG_UPDATE_SCREEN);
+        mAmbientStateAlarmManager.cancel(mAmbientStatePendingIntent);
+
+        super.onDestroy();
+    }
+
+    /**
+     * Prepares UI for Ambient view.
+     */
+    @Override
+    public void onEnterAmbient(Bundle ambientDetails) {
+        Log.d(TAG, "onEnterAmbient()");
+        super.onEnterAmbient(ambientDetails);
+
+        /**
+         * In this sample, we aren't using the ambient details bundle (EXTRA_BURN_IN_PROTECTION or
+         * EXTRA_LOWBIT_AMBIENT), but if you need them, you can pull them from the local variable
+         * set here.
+         */
+        mAmbientDetails = ambientDetails;
+
+        /** Clears Handler queue (only needed for updates in active mode). */
+        mActiveModeUpdateHandler.removeMessages(MSG_UPDATE_SCREEN);
+
+        /**
+         * Following best practices outlined in WatchFaces API (keeping most pixels black,
+         * avoiding large blocks of white pixels, using only black and white,
+         * and disabling anti-aliasing anti-aliasing, etc.)
+         */
+        mStateTextView.setTextColor(Color.WHITE);
+        mUpdateRateTextView.setTextColor(Color.WHITE);
+        mDrawCountTextView.setTextColor(Color.WHITE);
+
+        mTimeTextView.getPaint().setAntiAlias(false);
+        mTimeStampTextView.getPaint().setAntiAlias(false);
+        mStateTextView.getPaint().setAntiAlias(false);
+        mUpdateRateTextView.getPaint().setAntiAlias(false);
+        mDrawCountTextView.getPaint().setAntiAlias(false);
+
+        refreshDisplayAndSetNextUpdate();
+    }
+
+    /**
+     * Updates UI in Ambient view (once a minute). Because we need to update UI sooner than that
+     * (every ~20 seconds), we also use an Alarm. However, since the processor is awake for this
+     * callback, we might as well call refreshDisplayAndSetNextUpdate() to update screen and reset
+     * the Alarm.
+     *
+     * If you are happy with just updating the screen once a minute in Ambient Mode (which will be
+     * the case a majority of the time), then you can just use this method and remove all
+     * references/code regarding Alarms.
+     */
+    @Override
+    public void onUpdateAmbient() {
+        Log.d(TAG, "onUpdateAmbient()");
+        super.onUpdateAmbient();
+
+        refreshDisplayAndSetNextUpdate();
+    }
+
+    /**
+     * Prepares UI for Active view (non-Ambient).
+     */
+    @Override
+    public void onExitAmbient() {
+        Log.d(TAG, "onExitAmbient()");
+        super.onExitAmbient();
+
+        /** Clears out Alarms since they are only used in ambient mode. */
+        mAmbientStateAlarmManager.cancel(mAmbientStatePendingIntent);
+
+        mStateTextView.setTextColor(Color.GREEN);
+        mUpdateRateTextView.setTextColor(Color.GREEN);
+        mDrawCountTextView.setTextColor(Color.GREEN);
+
+        mTimeTextView.getPaint().setAntiAlias(true);
+        mTimeStampTextView.getPaint().setAntiAlias(true);
+        mStateTextView.getPaint().setAntiAlias(true);
+        mUpdateRateTextView.getPaint().setAntiAlias(true);
+        mDrawCountTextView.getPaint().setAntiAlias(true);
+
+        refreshDisplayAndSetNextUpdate();
+    }
+
+    /**
+     * Loads data/updates screen (via method), but most importantly, sets up the next refresh
+     * (active mode = Handler and ambient mode = Alarm).
+     */
+    private void refreshDisplayAndSetNextUpdate() {
+
+        loadDataAndUpdateScreen();
+
+        long timeMs = System.currentTimeMillis();
+
+        if (isAmbient()) {
+            /** Calculate next trigger time (based on state). */
+            long delayMs = AMBIENT_INTERVAL_MS - (timeMs % AMBIENT_INTERVAL_MS);
+            long triggerTimeMs = timeMs + delayMs;
+
+            /**
+             * Note: Make sure you have set activity launchMode to singleInstance in the manifest.
+             * Otherwise, it is easy for the AlarmManager launch intent to open a new activity
+             * every time the Alarm is triggered rather than reusing this Activity.
+             */
+            mAmbientStateAlarmManager.setExact(
+                    AlarmManager.RTC_WAKEUP,
+                    triggerTimeMs,
+                    mAmbientStatePendingIntent);
+
+        } else {
+            /** Calculate next trigger time (based on state). */
+            long delayMs = ACTIVE_INTERVAL_MS - (timeMs % ACTIVE_INTERVAL_MS);
+
+            mActiveModeUpdateHandler.removeMessages(MSG_UPDATE_SCREEN);
+            mActiveModeUpdateHandler.sendEmptyMessageDelayed(MSG_UPDATE_SCREEN, delayMs);
+        }
+    }
+
+    /**
+     * Updates display based on Ambient state. If you need to pull data, you should do it here.
+     */
+    private void loadDataAndUpdateScreen() {
+
+        mDrawCount += 1;
+        long currentTimeMs = System.currentTimeMillis();
+        Log.d(TAG, "loadDataAndUpdateScreen(): " + currentTimeMs + "(" + isAmbient() + ")");
+
+        if (isAmbient()) {
+
+            mTimeTextView.setText(sDateFormat.format(new Date()));
+            mTimeStampTextView.setText(getString(R.string.timestamp_label, currentTimeMs));
+
+            mStateTextView.setText(getString(R.string.mode_ambient_label));
+            mUpdateRateTextView.setText(
+                    getString(R.string.update_rate_label, (AMBIENT_INTERVAL_MS / 1000)));
+
+            mDrawCountTextView.setText(getString(R.string.draw_count_label, mDrawCount));
+
+        } else {
+            mTimeTextView.setText(sDateFormat.format(new Date()));
+            mTimeStampTextView.setText(getString(R.string.timestamp_label, currentTimeMs));
+
+            mStateTextView.setText(getString(R.string.mode_active_label));
+            mUpdateRateTextView.setText(
+                    getString(R.string.update_rate_label, (ACTIVE_INTERVAL_MS / 1000)));
+
+            mDrawCountTextView.setText(getString(R.string.draw_count_label, mDrawCount));
+        }
+    }
+
+    /**
+     * Handler separated into static class to avoid memory leaks.
+     */
+    private static class UpdateHandler extends Handler {
+        private final WeakReference<MainActivity> mMainActivityWeakReference;
+
+        public UpdateHandler(MainActivity reference) {
+            mMainActivityWeakReference = new WeakReference<MainActivity>(reference);
+        }
+
+        @Override
+        public void handleMessage(Message message) {
+            MainActivity mainActivity = mMainActivityWeakReference.get();
+
+            if (mainActivity != null) {
+                switch (message.what) {
+                    case MSG_UPDATE_SCREEN:
+                        mainActivity.refreshDisplayAndSetNextUpdate();
+                        break;
+                }
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/wearable/wear/AlwaysOn/Wearable/src/main/res/layout/activity_main.xml b/wearable/wear/AlwaysOn/Wearable/src/main/res/layout/activity_main.xml
new file mode 100644
index 0000000..d808e6b
--- /dev/null
+++ b/wearable/wear/AlwaysOn/Wearable/src/main/res/layout/activity_main.xml
@@ -0,0 +1,28 @@
+<?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.
+-->
+<android.support.wearable.view.WatchViewStub
+    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"
+    android:id="@+id/watch_view_stub"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    app:rectLayout="@layout/rect_activity_main"
+    app:roundLayout="@layout/round_activity_main"
+    tools:context=".MainActivity"
+    tools:deviceIds="wear">
+</android.support.wearable.view.WatchViewStub>
diff --git a/wearable/wear/AlwaysOn/Wearable/src/main/res/layout/rect_activity_main.xml b/wearable/wear/AlwaysOn/Wearable/src/main/res/layout/rect_activity_main.xml
new file mode 100644
index 0000000..bfb8147
--- /dev/null
+++ b/wearable/wear/AlwaysOn/Wearable/src/main/res/layout/rect_activity_main.xml
@@ -0,0 +1,59 @@
+<?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.
+-->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:paddingTop="@dimen/square_top_margin"
+    android:paddingLeft="@dimen/square_left_margin"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:orientation="vertical"
+    tools:context=".MainActivity"
+    tools:deviceIds="wear_square">
+
+    <TextView
+        android:id="@+id/time"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:textSize="24sp"
+        android:text="Hello, time!"/>
+
+    <TextView
+        android:id="@+id/time_stamp"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:text="Hello, timestamp!"/>
+
+    <TextView
+        android:id="@+id/state"
+        android:textColor="@color/green"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:text="Hello, state!"/>
+
+    <TextView
+        android:id="@+id/update_rate"
+        android:textColor="@color/green"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:text="Hello, update rate!"/>
+
+    <TextView
+        android:id="@+id/draw_count"
+        android:textColor="@color/green"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:text="Hello, draw count!"/>
+</LinearLayout>
diff --git a/wearable/wear/AlwaysOn/Wearable/src/main/res/layout/round_activity_main.xml b/wearable/wear/AlwaysOn/Wearable/src/main/res/layout/round_activity_main.xml
new file mode 100644
index 0000000..8fa7a2d
--- /dev/null
+++ b/wearable/wear/AlwaysOn/Wearable/src/main/res/layout/round_activity_main.xml
@@ -0,0 +1,59 @@
+<?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.
+-->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:paddingTop="@dimen/round_top_margin"
+    android:paddingLeft="@dimen/round_left_margin"
+    android:layout_width="match_parent"
+    android:orientation="vertical"
+    android:layout_height="match_parent"
+    tools:context=".MainActivity"
+    tools:deviceIds="wear_round">
+
+    <TextView
+        android:id="@+id/time"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:textSize="24sp"
+        android:text="Hello, time!"/>
+
+    <TextView
+        android:id="@+id/time_stamp"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:text="Hello, timestamp!"/>
+
+    <TextView
+        android:id="@+id/state"
+        android:textColor="@color/green"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:text="Hello, state!"/>
+
+    <TextView
+        android:id="@+id/update_rate"
+        android:textColor="@color/green"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:text="Hello, update rate!"/>
+
+    <TextView
+        android:id="@+id/draw_count"
+        android:textColor="@color/green"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:text="Hello, draw count!"/>
+</LinearLayout>
diff --git a/wearable/wear/AlwaysOn/Wearable/src/main/res/values/dimens.xml b/wearable/wear/AlwaysOn/Wearable/src/main/res/values/dimens.xml
new file mode 100644
index 0000000..d44096a
--- /dev/null
+++ b/wearable/wear/AlwaysOn/Wearable/src/main/res/values/dimens.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.
+-->
+<resources>
+    <!-- Default screen margins, per the Android Design guidelines. -->
+    <dimen name="square_top_margin">24dp</dimen>
+    <dimen name="square_left_margin">16dp</dimen>
+
+    <dimen name="round_top_margin">34dp</dimen>
+    <dimen name="round_left_margin">34dp</dimen>
+</resources>
diff --git a/wearable/wear/AlwaysOn/Wearable/src/main/res/values/strings.xml b/wearable/wear/AlwaysOn/Wearable/src/main/res/values/strings.xml
new file mode 100644
index 0000000..7d4c2f6
--- /dev/null
+++ b/wearable/wear/AlwaysOn/Wearable/src/main/res/values/strings.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.
+-->
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+    <string name="app_name">Always On Example</string>
+    <string name="timestamp_label">Timestamp: %1$d</string>
+    <string name="mode_active_label">Active Mode (Handler)</string>
+    <string name="mode_ambient_label">Ambient Mode (Alarm)</string>
+    <string name="update_rate_label">Update rate: %1$d sec</string>
+    <string name="draw_count_label">Draw count: %1$d</string>
+</resources>
diff --git a/wearable/wear/AlwaysOn/build.gradle b/wearable/wear/AlwaysOn/build.gradle
new file mode 100644
index 0000000..18f393f
--- /dev/null
+++ b/wearable/wear/AlwaysOn/build.gradle
@@ -0,0 +1,11 @@
+
+// BEGIN_EXCLUDE
+import com.example.android.samples.build.SampleGenPlugin
+apply plugin: SampleGenPlugin
+
+samplegen {
+  pathToBuild "../../../../../build"
+  pathToSamplesCommon "../../../common"
+}
+apply from: "../../../../../build/build.gradle"
+// END_EXCLUDE
diff --git a/wearable/wear/AlwaysOn/buildSrc/build.gradle b/wearable/wear/AlwaysOn/buildSrc/build.gradle
new file mode 100644
index 0000000..7cebf71
--- /dev/null
+++ b/wearable/wear/AlwaysOn/buildSrc/build.gradle
@@ -0,0 +1,15 @@
+repositories {
+    mavenCentral()
+}
+dependencies {
+    compile 'org.freemarker:freemarker:2.3.20'
+}
+
+sourceSets {
+    main {
+        groovy {
+            srcDir new File(rootDir, "../../../../../../build/buildSrc/src/main/groovy")
+        }
+    }
+}
+
diff --git a/wearable/wear/AlwaysOn/gradle/wrapper/gradle-wrapper.jar b/wearable/wear/AlwaysOn/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..8c0fb64
--- /dev/null
+++ b/wearable/wear/AlwaysOn/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/wearable/wear/AlwaysOn/gradle/wrapper/gradle-wrapper.properties b/wearable/wear/AlwaysOn/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..7d3b483
--- /dev/null
+++ b/wearable/wear/AlwaysOn/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Mon Dec 22 11:24:44 EST 2014
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
diff --git a/wearable/wear/AlwaysOn/gradlew b/wearable/wear/AlwaysOn/gradlew
new file mode 100755
index 0000000..91a7e26
--- /dev/null
+++ b/wearable/wear/AlwaysOn/gradlew
@@ -0,0 +1,164 @@
+#!/usr/bin/env bash
+
+##############################################################################
+##
+##  Gradle start up script for UN*X
+##
+##############################################################################
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+    echo "$*"
+}
+
+die ( ) {
+    echo
+    echo "$*"
+    echo
+    exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+case "`uname`" in
+  CYGWIN* )
+    cygwin=true
+    ;;
+  Darwin* )
+    darwin=true
+    ;;
+  MINGW* )
+    msys=true
+    ;;
+esac
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched.
+if $cygwin ; then
+    [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+fi
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+    ls=`ls -ld "$PRG"`
+    link=`expr "$ls" : '.*-> \(.*\)$'`
+    if expr "$link" : '/.*' > /dev/null; then
+        PRG="$link"
+    else
+        PRG=`dirname "$PRG"`"/$link"
+    fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >&-
+APP_HOME="`pwd -P`"
+cd "$SAVED" >&-
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+        # IBM's JDK on AIX uses strange locations for the executables
+        JAVACMD="$JAVA_HOME/jre/sh/java"
+    else
+        JAVACMD="$JAVA_HOME/bin/java"
+    fi
+    if [ ! -x "$JAVACMD" ] ; then
+        die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+    fi
+else
+    JAVACMD="java"
+    which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+    MAX_FD_LIMIT=`ulimit -H -n`
+    if [ $? -eq 0 ] ; then
+        if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+            MAX_FD="$MAX_FD_LIMIT"
+        fi
+        ulimit -n $MAX_FD
+        if [ $? -ne 0 ] ; then
+            warn "Could not set maximum file descriptor limit: $MAX_FD"
+        fi
+    else
+        warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+    fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+    GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+    APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+    CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+
+    # We build the pattern for arguments to be converted via cygpath
+    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+    SEP=""
+    for dir in $ROOTDIRSRAW ; do
+        ROOTDIRS="$ROOTDIRS$SEP$dir"
+        SEP="|"
+    done
+    OURCYGPATTERN="(^($ROOTDIRS))"
+    # Add a user-defined pattern to the cygpath arguments
+    if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+        OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+    fi
+    # Now convert the arguments - kludge to limit ourselves to /bin/sh
+    i=0
+    for arg in "$@" ; do
+        CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+        CHECK2=`echo "$arg"|egrep -c "^-"`                                 ### Determine if an option
+
+        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition
+            eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+        else
+            eval `echo args$i`="\"$arg\""
+        fi
+        i=$((i+1))
+    done
+    case $i in
+        (0) set -- ;;
+        (1) set -- "$args0" ;;
+        (2) set -- "$args0" "$args1" ;;
+        (3) set -- "$args0" "$args1" "$args2" ;;
+        (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+        (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+        (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+        (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+        (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+        (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+    esac
+fi
+
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+    JVM_OPTS=("$@")
+}
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/wearable/wear/AlwaysOn/gradlew.bat b/wearable/wear/AlwaysOn/gradlew.bat
new file mode 100644
index 0000000..aec9973
--- /dev/null
+++ b/wearable/wear/AlwaysOn/gradlew.bat
@@ -0,0 +1,90 @@
+@if "%DEBUG%" == "" @echo off

+@rem ##########################################################################

+@rem

+@rem  Gradle startup script for Windows

+@rem

+@rem ##########################################################################

+

+@rem Set local scope for the variables with windows NT shell

+if "%OS%"=="Windows_NT" setlocal

+

+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.

+set DEFAULT_JVM_OPTS=

+

+set DIRNAME=%~dp0

+if "%DIRNAME%" == "" set DIRNAME=.

+set APP_BASE_NAME=%~n0

+set APP_HOME=%DIRNAME%

+

+@rem Find java.exe

+if defined JAVA_HOME goto findJavaFromJavaHome

+

+set JAVA_EXE=java.exe

+%JAVA_EXE% -version >NUL 2>&1

+if "%ERRORLEVEL%" == "0" goto init

+

+echo.

+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.

+echo.

+echo Please set the JAVA_HOME variable in your environment to match the

+echo location of your Java installation.

+

+goto fail

+

+:findJavaFromJavaHome

+set JAVA_HOME=%JAVA_HOME:"=%

+set JAVA_EXE=%JAVA_HOME%/bin/java.exe

+

+if exist "%JAVA_EXE%" goto init

+

+echo.

+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%

+echo.

+echo Please set the JAVA_HOME variable in your environment to match the

+echo location of your Java installation.

+

+goto fail

+

+:init

+@rem Get command-line arguments, handling Windowz variants

+

+if not "%OS%" == "Windows_NT" goto win9xME_args

+if "%@eval[2+2]" == "4" goto 4NT_args

+

+:win9xME_args

+@rem Slurp the command line arguments.

+set CMD_LINE_ARGS=

+set _SKIP=2

+

+:win9xME_args_slurp

+if "x%~1" == "x" goto execute

+

+set CMD_LINE_ARGS=%*

+goto execute

+

+:4NT_args

+@rem Get arguments from the 4NT Shell from JP Software

+set CMD_LINE_ARGS=%$

+

+:execute

+@rem Setup the command line

+

+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

+

+@rem Execute Gradle

+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%

+

+:end

+@rem End local scope for the variables with windows NT shell

+if "%ERRORLEVEL%"=="0" goto mainEnd

+

+:fail

+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of

+rem the _cmd.exe /c_ return code!

+if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1

+exit /b 1

+

+:mainEnd

+if "%OS%"=="Windows_NT" endlocal

+

+:omega

diff --git a/wearable/wear/AlwaysOn/screenshots/1-main-active.png b/wearable/wear/AlwaysOn/screenshots/1-main-active.png
new file mode 100644
index 0000000..cf5db84
--- /dev/null
+++ b/wearable/wear/AlwaysOn/screenshots/1-main-active.png
Binary files differ
diff --git a/wearable/wear/AlwaysOn/screenshots/2-main-ambient.png b/wearable/wear/AlwaysOn/screenshots/2-main-ambient.png
new file mode 100644
index 0000000..b871fce
--- /dev/null
+++ b/wearable/wear/AlwaysOn/screenshots/2-main-ambient.png
Binary files differ
diff --git a/wearable/wear/AlwaysOn/screenshots/3-main-active-round.png b/wearable/wear/AlwaysOn/screenshots/3-main-active-round.png
new file mode 100644
index 0000000..6acb920
--- /dev/null
+++ b/wearable/wear/AlwaysOn/screenshots/3-main-active-round.png
Binary files differ
diff --git a/wearable/wear/AlwaysOn/screenshots/4-main-ambient-round.png b/wearable/wear/AlwaysOn/screenshots/4-main-ambient-round.png
new file mode 100644
index 0000000..2a56f89
--- /dev/null
+++ b/wearable/wear/AlwaysOn/screenshots/4-main-ambient-round.png
Binary files differ
diff --git a/wearable/wear/AlwaysOn/template-params.xml b/wearable/wear/AlwaysOn/template-params.xml
new file mode 100644
index 0000000..e5794ee
--- /dev/null
+++ b/wearable/wear/AlwaysOn/template-params.xml
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<sample>
+    <name>AlwaysOn</name>
+    <group>Wearable</group>
+    <package>com.example.android.wearable.wear.alwayson</package>
+
+    <dependency_wearable>com.google.android.support:wearable:1.2.0</dependency_wearable>
+    <provided_dependency_wearable>com.google.android.wearable:wearable:1.0.0</provided_dependency_wearable>
+
+    <minSdk>20</minSdk>
+    <targetSdkVersion>22</targetSdkVersion>
+
+    <strings>
+        <intro>
+            <![CDATA[
+            Demonstrates a native Android Wear app using ambient screen support.
+            ]]>>
+        </intro>
+    </strings>
+
+    <template src="base-build" />
+    <template src="Wear" />
+
+    <!-- Include common code modules by uncommenting them below. -->
+    <!-- common src="logger"/ -->
+
+    <metadata>
+        <status>PUBLISHED</status>
+        <categories>Wearable</categories>
+        <technologies>Android</technologies>
+        <languages>Java</languages>
+        <solutions>Mobile</solutions>
+        <level>INTERMEDIATE</level>
+        <screenshots>
+            <img>screenshots/1-main-active.png</img>
+            <img>screenshots/2-main-ambient.png</img>
+            <img>screenshots/3-main-active-round.png</img>
+            <img>screenshots/4-main-ambient-round.png</img>
+        </screenshots>
+        <api_refs>
+            <android>android.support.wearable.activity.WearableActivity</android>
+        </api_refs>
+        <description>
+            <![CDATA[
+A basic sample showing how to support ambient mode for native Android Wear apps.
+]]>
+        </description>
+
+        <intro>
+            <![CDATA[
+[WearableActivity][1] offers methods for supporting your native app staying on the screen when the Wear device enters ambient mode.
+
+This example extends [WearableActivity][1] and overrides onEnterAmbient, onUpdateAmbient, and onExitAmbient to allow the simple native Wear app to support ambient mode.
+
+In ambient mode, this app follows best practices by keeping most pixels black, avoiding large blocks of white pixels, using only black and white, and disabling anti-aliasing (following the [design guidelines for Watch Faces][2]).
+
+In addition and most importantly, the app sleeps while in ambient mode for 20 seconds between any updates to conserving battery life (processor allowed to sleep). If you can hold off on updates for a full minute, you can throw away the Handler and just use onUpdateAmbient to save even more battery life.
+
+As always, you will still want to apply the [performance guidelines][3] outlined in the Watch Faces documention to your app.
+
+[1]: http://developer.android.com/reference/android/support/wearable/activity/WearableActivity.html
+[2]: https://developer.android.com/training/wearables/watch-faces/designing.html#DesignGuidelines
+[3]: https://developer.android.com/training/wearables/watch-faces/performance.html
+]]>
+        </intro>
+    </metadata>
+</sample>
\ No newline at end of file
diff --git a/wearable/wear/Geofencing/Application/src/main/java/com/example/android/wearable/geofencing/MainActivity.java b/wearable/wear/Geofencing/Application/src/main/java/com/example/android/wearable/geofencing/MainActivity.java
index 350c9c5..7564e6c 100644
--- a/wearable/wear/Geofencing/Application/src/main/java/com/example/android/wearable/geofencing/MainActivity.java
+++ b/wearable/wear/Geofencing/Application/src/main/java/com/example/android/wearable/geofencing/MainActivity.java
@@ -37,7 +37,7 @@
 import android.widget.Toast;
 
 import com.google.android.gms.common.ConnectionResult;
-import com.google.android.gms.common.GooglePlayServicesClient.ConnectionCallbacks;
+import com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks;
 import com.google.android.gms.common.GooglePlayServicesUtil;
 import com.google.android.gms.common.api.GoogleApiClient;
 import com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener;
@@ -48,7 +48,7 @@
 import java.util.List;
 
 public class MainActivity extends Activity implements ConnectionCallbacks,
-        OnConnectionFailedListener, GoogleApiClient.ConnectionCallbacks {
+        OnConnectionFailedListener {
 
     // Internal List of Geofence objects. In a real app, these might be provided by an API based on
     // locations within the user's proximity.
@@ -143,10 +143,6 @@
         }
     }
 
-    @Override
-    public void onDisconnected() {
-    }
-
     /**
      * Once the connection is available, send a request to add the Geofences.
      */
diff --git a/wearable/wear/Geofencing/template-params.xml b/wearable/wear/Geofencing/template-params.xml
index 6e66ecc..66bfcc0 100644
--- a/wearable/wear/Geofencing/template-params.xml
+++ b/wearable/wear/Geofencing/template-params.xml
@@ -23,7 +23,7 @@
     <package>com.example.android.wearable.geofencing</package>
 
     <minSdk>18</minSdk>
-    <dependency>com.google.android.gms:play-services-location:6.5.+</dependency>
+    <dependency>com.google.android.gms:play-services-location:7.3.0</dependency>
 
     <wearable>
         <has_handheld_app>true</has_handheld_app>
diff --git a/wearable/wear/SpeedTracker/template-params.xml b/wearable/wear/SpeedTracker/template-params.xml
index 6287a2a..71c5ac2 100644
--- a/wearable/wear/SpeedTracker/template-params.xml
+++ b/wearable/wear/SpeedTracker/template-params.xml
@@ -28,8 +28,8 @@
         <has_handheld_app>true</has_handheld_app>
     </wearable>
 
-    <dependency>com.google.android.gms:play-services-location:6.5.+</dependency>
-    <dependency_wearable>com.google.android.gms:play-services-location:6.5.+</dependency_wearable>
+    <dependency>com.google.android.gms:play-services-location:7.3.0</dependency>
+    <dependency_wearable>com.google.android.gms:play-services-location:7.3.0</dependency_wearable>
 
 
     <strings>