Merge "AppRestrictionSchema, Enforcer: More restrictions" into lmp-docs
diff --git a/content/contacts/BasicContactables/screenshots/1-main.png b/content/contacts/BasicContactables/screenshots/1-main.png
new file mode 100644
index 0000000..2c11a7d
--- /dev/null
+++ b/content/contacts/BasicContactables/screenshots/1-main.png
Binary files differ
diff --git a/content/contacts/BasicContactables/screenshots/2-search.png b/content/contacts/BasicContactables/screenshots/2-search.png
new file mode 100644
index 0000000..b8b012f
--- /dev/null
+++ b/content/contacts/BasicContactables/screenshots/2-search.png
Binary files differ
diff --git a/content/contacts/BasicContactables/screenshots/3-results.png b/content/contacts/BasicContactables/screenshots/3-results.png
new file mode 100644
index 0000000..48856ce
--- /dev/null
+++ b/content/contacts/BasicContactables/screenshots/3-results.png
Binary files differ
diff --git a/content/contacts/BasicContactables/screenshots/icon-web.png b/content/contacts/BasicContactables/screenshots/icon-web.png
new file mode 100644
index 0000000..8ad9e14
--- /dev/null
+++ b/content/contacts/BasicContactables/screenshots/icon-web.png
Binary files differ
diff --git a/content/contacts/BasicContactables/template-params.xml b/content/contacts/BasicContactables/template-params.xml
index ee2ba11..01274ae 100644
--- a/content/contacts/BasicContactables/template-params.xml
+++ b/content/contacts/BasicContactables/template-params.xml
@@ -38,4 +38,51 @@
     <template src="base"/>
     <common src="logger"/>
 
+    <metadata>
+        <status>PUBLISHED</status>
+        <categories>Content</categories>
+        <technologies>Android</technologies>
+        <languages>Java</languages>
+        <solutions>Mobile</solutions>
+        <level>INTERMEDIATE</level>
+        <icon>screenshots/icon-web.png</icon>
+        <screenshots>
+            <img>screenshots/1-main.png</img>
+            <img>screenshots/2-search.png</img>
+            <img>screenshots/3-results.png</img>
+        </screenshots>
+        <api_refs>
+            <android>android.app.SearchManager</android>
+            <android>android.widget.SearchView</android>
+            <android>android.app.LoaderManager</android>
+            <android>android.content.CursorLoader</android>
+            <android>android.provider.ContactsContract.CommonDataKinds</android>
+        </api_refs>
+
+        <description>
+<![CDATA[
+This sample shows how to search for contacts, displaying a SearchView in the Action Bar for user input and implementing a query Cursor with CommonDataKinds.Contactables.
+]]>
+        </description>
+
+        <intro>
+<![CDATA[
+This sample displays a [SearchView][1] in the Action Bar when the search icon is clicked. It then implements the [LoaderManager.LoaderCallbacks][2] interface to query the contacts table, using a [CursorLoader][3].
+
+For details on how to implement the [SearchView][1], refer to the training guide [Setting up the search interface][4].
+
+For details on how to implement the [LoaderManager.LoaderCallbacks][2] interface, refer to the [Using the LoaderManager Callbacks][5] guide.
+
+For details on how to query the contacts provider, refer to the [Contacts Provider Access][6] guide.
+
+[1]: http://developer.android.com/reference/android/widget/SearchView.html
+[2]: http://developer.android.com/reference/android/app/LoaderManager.LoaderCallbacks.html
+[3]: http://developer.android.com/reference/android/content/CursorLoader.html
+[4]: http://developer.android.com/training/search/setup.html
+[5]: http://developer.android.com/guide/components/loaders.html#callback
+[6]: http://developer.android.com/guide/topics/providers/contacts-provider.html#Access
+]]>
+        </intro>
+    </metadata>
+
 </sample>
diff --git a/content/documentsUi/DirectorySelection/Application/.gitignore b/content/documentsUi/DirectorySelection/Application/.gitignore
new file mode 100644
index 0000000..6eb878d
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/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/content/documentsUi/DirectorySelection/Application/proguard-project.txt b/content/documentsUi/DirectorySelection/Application/proguard-project.txt
new file mode 100644
index 0000000..0d8f171
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/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/content/documentsUi/DirectorySelection/Application/src/main/AndroidManifest.xml b/content/documentsUi/DirectorySelection/Application/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..46cddcf
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/src/main/AndroidManifest.xml
@@ -0,0 +1,37 @@
+<?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.directoryselection"
+    android:versionCode="1"
+    android:versionName="1.0">
+
+    <application android:allowBackup="true"
+        android:label="@string/app_name"
+        android:icon="@drawable/ic_launcher"
+        android:theme="@style/AppTheme">
+
+        <activity android:name=".DirectorySelectionActivity"
+                  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/content/documentsUi/DirectorySelection/Application/src/main/java/com/example/android/directoryselection/DirectoryEntry.java b/content/documentsUi/DirectorySelection/Application/src/main/java/com/example/android/directoryselection/DirectoryEntry.java
new file mode 100644
index 0000000..04c1c89
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/src/main/java/com/example/android/directoryselection/DirectoryEntry.java
@@ -0,0 +1,25 @@
+/*
+* Copyright (C) 2014 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package com.example.android.directoryselection;
+
+/**
+ * Entity class that represents an directory entry.
+ */
+public class DirectoryEntry {
+    public String fileName;
+    public String mimeType;
+}
diff --git a/content/documentsUi/DirectorySelection/Application/src/main/java/com/example/android/directoryselection/DirectoryEntryAdapter.java b/content/documentsUi/DirectorySelection/Application/src/main/java/com/example/android/directoryselection/DirectoryEntryAdapter.java
new file mode 100644
index 0000000..e92c71e
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/src/main/java/com/example/android/directoryselection/DirectoryEntryAdapter.java
@@ -0,0 +1,100 @@
+/*
+* Copyright (C) 2014 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package com.example.android.directoryselection;
+
+import android.support.v7.widget.RecyclerView;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import java.util.List;
+
+/**
+ * Provide views to RecyclerView with the directory entries.
+ */
+public class DirectoryEntryAdapter extends RecyclerView.Adapter<DirectoryEntryAdapter.ViewHolder> {
+
+    static final String DIRECTORY_MIME_TYPE = "vnd.android.document/directory";
+    private List<DirectoryEntry> mDirectoryEntries;
+
+    /**
+     * Provide a reference to the type of views that you are using (custom ViewHolder)
+     */
+    public static class ViewHolder extends RecyclerView.ViewHolder {
+        private final TextView mFileName;
+        private final TextView mMimeType;
+        private final ImageView mImageView;
+
+        public ViewHolder(View v) {
+            super(v);
+            mFileName = (TextView) v.findViewById(R.id.textview_filename);
+            mMimeType = (TextView) v.findViewById(R.id.textview_mimetype);
+            mImageView = (ImageView) v.findViewById(R.id.entry_image);
+        }
+
+        public TextView getFileName() {
+            return mFileName;
+        }
+
+        public TextView getMimeType() {
+            return mMimeType;
+        }
+
+        public ImageView getImageView() {
+            return mImageView;
+        }
+    }
+
+    /**
+     * Initialize the directory entries of the Adapter.
+     *
+     * @param directoryEntries an array of {@link DirectoryEntry}.
+     */
+    public DirectoryEntryAdapter(List<DirectoryEntry> directoryEntries) {
+        mDirectoryEntries = directoryEntries;
+    }
+
+    @Override
+    public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
+        View v = LayoutInflater.from(viewGroup.getContext())
+                .inflate(R.layout.directory_item, viewGroup, false);
+        return new ViewHolder(v);
+    }
+
+    @Override
+    public void onBindViewHolder(ViewHolder viewHolder, final int position) {
+        viewHolder.getFileName().setText(mDirectoryEntries.get(position).fileName);
+        viewHolder.getMimeType().setText(mDirectoryEntries.get(position).mimeType);
+
+        if (DIRECTORY_MIME_TYPE.equals(mDirectoryEntries.get(position).mimeType)) {
+            viewHolder.getImageView().setImageResource(R.drawable.ic_folder_grey600_36dp);
+        } else {
+            viewHolder.getImageView().setImageResource(R.drawable.ic_description_grey600_36dp);
+        }
+    }
+
+    @Override
+    public int getItemCount() {
+        return mDirectoryEntries.size();
+    }
+
+    public void setDirectoryEntries(List<DirectoryEntry> directoryEntries) {
+        mDirectoryEntries = directoryEntries;
+    }
+}
diff --git a/content/documentsUi/DirectorySelection/Application/src/main/java/com/example/android/directoryselection/DirectorySelectionActivity.java b/content/documentsUi/DirectorySelection/Application/src/main/java/com/example/android/directoryselection/DirectorySelectionActivity.java
new file mode 100644
index 0000000..d27ba72
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/src/main/java/com/example/android/directoryselection/DirectorySelectionActivity.java
@@ -0,0 +1,37 @@
+/*
+* Copyright 2014 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package com.example.android.directoryselection;
+
+import android.os.Bundle;
+import android.support.v4.app.FragmentActivity;
+
+/**
+ * Launcher Activity for the Directory Selection sample app.
+ */
+public class DirectorySelectionActivity extends FragmentActivity {
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_directory_selection);
+        if (savedInstanceState == null) {
+            getSupportFragmentManager().beginTransaction()
+                    .add(R.id.container, DirectorySelectionFragment.newInstance())
+                    .commit();
+        }
+    }
+}
diff --git a/content/documentsUi/DirectorySelection/Application/src/main/java/com/example/android/directoryselection/DirectorySelectionFragment.java b/content/documentsUi/DirectorySelection/Application/src/main/java/com/example/android/directoryselection/DirectorySelectionFragment.java
new file mode 100644
index 0000000..4af55db
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/src/main/java/com/example/android/directoryselection/DirectorySelectionFragment.java
@@ -0,0 +1,231 @@
+/*
+* Copyright 2014 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package com.example.android.directoryselection;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.ContentResolver;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.database.Cursor;
+import android.net.Uri;
+import android.os.Bundle;
+import android.provider.DocumentsContract;
+import android.provider.DocumentsContract.Document;
+import android.support.v4.app.Fragment;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Fragment that demonstrates how to use Directory Selection API.
+ */
+public class DirectorySelectionFragment extends Fragment {
+
+    private static final String TAG = DirectorySelectionFragment.class.getSimpleName();
+
+    public static final int REQUEST_CODE_OPEN_DIRECTORY = 1;
+
+    Uri mCurrentDirectoryUri;
+    TextView mCurrentDirectoryTextView;
+    Button mCreateDirectoryButton;
+    RecyclerView mRecyclerView;
+    DirectoryEntryAdapter mAdapter;
+    RecyclerView.LayoutManager mLayoutManager;
+
+    /**
+     * Use this factory method to create a new instance of
+     * this fragment using the provided parameters.
+     *
+     * @return A new instance of fragment {@link DirectorySelectionFragment}.
+     */
+    public static DirectorySelectionFragment newInstance() {
+        DirectorySelectionFragment fragment = new DirectorySelectionFragment();
+        return fragment;
+    }
+
+    public DirectorySelectionFragment() {
+        // Required empty public constructor
+    }
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+    }
+
+    @Override
+    public View onCreateView(LayoutInflater inflater, ViewGroup container,
+            Bundle savedInstanceState) {
+        // Inflate the layout for this fragment
+        return inflater.inflate(R.layout.fragment_directory_selection, container, false);
+    }
+
+    @Override
+    public void onViewCreated(View rootView, Bundle savedInstanceState) {
+        super.onViewCreated(rootView, savedInstanceState);
+
+        rootView.findViewById(R.id.button_open_directory)
+                .setOnClickListener(new View.OnClickListener() {
+                    @Override
+                    public void onClick(View v) {
+                        Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
+                        startActivityForResult(intent, REQUEST_CODE_OPEN_DIRECTORY);
+                    }
+                });
+
+        mCurrentDirectoryTextView = (TextView) rootView
+                .findViewById(R.id.textview_current_directory);
+        mCreateDirectoryButton = (Button) rootView.findViewById(R.id.button_create_directory);
+        mCreateDirectoryButton.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                final EditText editView = new EditText(getActivity());
+                new AlertDialog.Builder(getActivity())
+                        .setTitle(R.string.create_directory)
+                        .setView(editView)
+                        .setPositiveButton(android.R.string.ok,
+                                new DialogInterface.OnClickListener() {
+                                    public void onClick(DialogInterface dialog, int whichButton) {
+                                        createDirectory(mCurrentDirectoryUri,
+                                                editView.getText().toString());
+                                        updateDirectoryEntries(mCurrentDirectoryUri);
+                                    }
+                                })
+                        .setNegativeButton(android.R.string.cancel,
+                                new DialogInterface.OnClickListener() {
+                                    public void onClick(DialogInterface dialog, int whichButton) {
+                                    }
+                                })
+                        .show();
+            }
+        });
+        mRecyclerView = (RecyclerView) rootView.findViewById(R.id.recyclerview_directory_entries);
+        mLayoutManager = new LinearLayoutManager(getActivity());
+        mRecyclerView.setLayoutManager(mLayoutManager);
+        mRecyclerView.scrollToPosition(0);
+        mAdapter = new DirectoryEntryAdapter(new ArrayList<DirectoryEntry>());
+        mRecyclerView.setAdapter(mAdapter);
+    }
+
+    @Override
+    public void onActivityResult(int requestCode, int resultCode, Intent data) {
+        super.onActivityResult(requestCode, resultCode, data);
+        if (requestCode == REQUEST_CODE_OPEN_DIRECTORY && resultCode == Activity.RESULT_OK) {
+            Log.d(TAG, String.format("Open Directory result Uri : %s", data.getData()));
+            updateDirectoryEntries(data.getData());
+            mAdapter.notifyDataSetChanged();
+        }
+    }
+
+
+    /**
+     * Updates the current directory of the uri passed as an argument and its children directories.
+     * And updates the {@link #mRecyclerView} depending on the contents of the children.
+     *
+     * @param uri The uri of the current directory.
+     */
+    //VisibileForTesting
+    void updateDirectoryEntries(Uri uri) {
+        ContentResolver contentResolver = getActivity().getContentResolver();
+        Uri docUri = DocumentsContract.buildDocumentUriUsingTree(uri,
+                DocumentsContract.getTreeDocumentId(uri));
+        Uri childrenUri = DocumentsContract.buildChildDocumentsUriUsingTree(uri,
+                DocumentsContract.getTreeDocumentId(uri));
+
+        Cursor docCursor = contentResolver.query(docUri, new String[]{
+                Document.COLUMN_DISPLAY_NAME, Document.COLUMN_MIME_TYPE}, null, null, null);
+        try {
+            while (docCursor.moveToNext()) {
+                Log.d(TAG, "found doc =" + docCursor.getString(0) + ", mime=" + docCursor
+                        .getString(1));
+                mCurrentDirectoryUri = uri;
+                mCurrentDirectoryTextView.setText(docCursor.getString(0));
+                mCreateDirectoryButton.setEnabled(true);
+            }
+        } finally {
+            closeQuietly(docCursor);
+        }
+
+        Cursor childCursor = contentResolver.query(childrenUri, new String[]{
+                Document.COLUMN_DISPLAY_NAME, Document.COLUMN_MIME_TYPE}, null, null, null);
+        try {
+            List<DirectoryEntry> directoryEntries = new ArrayList<>();
+            while (childCursor.moveToNext()) {
+                Log.d(TAG, "found child=" + childCursor.getString(0) + ", mime=" + childCursor
+                        .getString(1));
+                DirectoryEntry entry = new DirectoryEntry();
+                entry.fileName = childCursor.getString(0);
+                entry.mimeType = childCursor.getString(1);
+                directoryEntries.add(entry);
+            }
+            mAdapter.setDirectoryEntries(directoryEntries);
+            mAdapter.notifyDataSetChanged();
+        } finally {
+            closeQuietly(childCursor);
+        }
+    }
+
+    /**
+     * Creates a directory under the directory represented as the uri in the argument.
+     *
+     * @param uri The uri of the directory under which a new directory is created.
+     * @param directoryName The directory name of a new directory.
+     */
+    //VisibileForTesting
+    void createDirectory(Uri uri, String directoryName) {
+        ContentResolver contentResolver = getActivity().getContentResolver();
+        Uri docUri = DocumentsContract.buildDocumentUriUsingTree(uri,
+                DocumentsContract.getTreeDocumentId(uri));
+        Uri directoryUri = DocumentsContract
+                .createDocument(contentResolver, docUri, Document.MIME_TYPE_DIR, directoryName);
+        if (directoryUri != null) {
+            Log.i(TAG, String.format(
+                    "Created directory : %s, Document Uri : %s, Created directory Uri : %s",
+                    directoryName, docUri, directoryUri));
+            Toast.makeText(getActivity(), String.format("Created a directory [%s]",
+                    directoryName), Toast.LENGTH_SHORT).show();
+        } else {
+            Log.w(TAG, String.format("Failed to create a directory : %s, Uri %s", directoryName,
+                    docUri));
+            Toast.makeText(getActivity(), String.format("Failed to created a directory [%s] : ",
+                    directoryName), Toast.LENGTH_SHORT).show();
+        }
+
+    }
+
+    public void closeQuietly(AutoCloseable closeable) {
+        if (closeable != null) {
+            try {
+                closeable.close();
+            } catch (RuntimeException rethrown) {
+                throw rethrown;
+            } catch (Exception ignored) {
+            }
+        }
+    }
+}
+
diff --git a/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-hdpi/ic_description_grey600_36dp.png b/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-hdpi/ic_description_grey600_36dp.png
new file mode 100755
index 0000000..dd7d073
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-hdpi/ic_description_grey600_36dp.png
Binary files differ
diff --git a/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-hdpi/ic_folder_grey600_36dp.png b/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-hdpi/ic_folder_grey600_36dp.png
new file mode 100755
index 0000000..6c022d4
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-hdpi/ic_folder_grey600_36dp.png
Binary files differ
diff --git a/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-hdpi/ic_launcher.png b/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-hdpi/ic_launcher.png
new file mode 100755
index 0000000..49ee854
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-hdpi/ic_launcher.png
Binary files differ
diff --git a/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-mdpi/ic_description_grey600_36dp.png b/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-mdpi/ic_description_grey600_36dp.png
new file mode 100755
index 0000000..ac18b57
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-mdpi/ic_description_grey600_36dp.png
Binary files differ
diff --git a/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-mdpi/ic_folder_grey600_36dp.png b/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-mdpi/ic_folder_grey600_36dp.png
new file mode 100755
index 0000000..e3dccd2
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-mdpi/ic_folder_grey600_36dp.png
Binary files differ
diff --git a/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-mdpi/ic_launcher.png b/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-mdpi/ic_launcher.png
new file mode 100755
index 0000000..282a00c
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-mdpi/ic_launcher.png
Binary files differ
diff --git a/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-xhdpi/ic_description_grey600_36dp.png b/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-xhdpi/ic_description_grey600_36dp.png
new file mode 100755
index 0000000..50f854e
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-xhdpi/ic_description_grey600_36dp.png
Binary files differ
diff --git a/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-xhdpi/ic_folder_grey600_36dp.png b/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-xhdpi/ic_folder_grey600_36dp.png
new file mode 100755
index 0000000..6fbc404
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-xhdpi/ic_folder_grey600_36dp.png
Binary files differ
diff --git a/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-xhdpi/ic_launcher.png b/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-xhdpi/ic_launcher.png
new file mode 100755
index 0000000..7293ad6
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-xhdpi/ic_launcher.png
Binary files differ
diff --git a/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-xxhdpi/ic_description_grey600_36dp.png b/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-xxhdpi/ic_description_grey600_36dp.png
new file mode 100755
index 0000000..33df5d9
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-xxhdpi/ic_description_grey600_36dp.png
Binary files differ
diff --git a/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-xxhdpi/ic_folder_grey600_36dp.png b/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-xxhdpi/ic_folder_grey600_36dp.png
new file mode 100755
index 0000000..ed2f08e
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-xxhdpi/ic_folder_grey600_36dp.png
Binary files differ
diff --git a/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-xxhdpi/ic_launcher.png b/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-xxhdpi/ic_launcher.png
new file mode 100755
index 0000000..7b618d4
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/src/main/res/drawable-xxhdpi/ic_launcher.png
Binary files differ
diff --git a/content/documentsUi/DirectorySelection/Application/src/main/res/layout/activity_directory_selection.xml b/content/documentsUi/DirectorySelection/Application/src/main/res/layout/activity_directory_selection.xml
new file mode 100644
index 0000000..db65583
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/src/main/res/layout/activity_directory_selection.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+             xmlns:tools="http://schemas.android.com/tools"
+             android:id="@+id/container"
+             android:layout_width="match_parent"
+             android:layout_height="match_parent"
+             tools:context="com.example.android.directoryselection.DirectorySelectionActivity"
+             tools:ignore="MergeRootFrame" />
\ No newline at end of file
diff --git a/content/documentsUi/DirectorySelection/Application/src/main/res/layout/directory_item.xml b/content/documentsUi/DirectorySelection/Application/src/main/res/layout/directory_item.xml
new file mode 100644
index 0000000..0763cff
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/src/main/res/layout/directory_item.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                android:layout_width="match_parent"
+                android:layout_height="@dimen/directory_item_height"
+        >
+
+    <LinearLayout android:layout_width="wrap_content"
+                  android:layout_height="wrap_content"
+                  android:orientation="horizontal"
+                  android:layout_centerVertical="true"
+                  android:gravity="center_vertical"
+            >
+        <ImageView android:id="@+id/entry_image"
+                   android:layout_width="wrap_content"
+                   android:layout_height="wrap_content"
+                   android:src="@drawable/ic_folder_grey600_36dp"
+                />
+        <LinearLayout android:layout_width="wrap_content"
+                      android:layout_height="wrap_content"
+                      android:layout_marginLeft="@dimen/margin_medium"
+                      android:orientation="vertical"
+                >
+            <View android:id="@+id/divisor"
+                  android:layout_width="match_parent"
+                  android:layout_height="1dp"
+                  android:background="#aaaaaa"/>
+
+            <TextView
+                    android:id="@+id/textview_filename"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    style="@style/DirectoryEntryNameFont"
+                    />
+            <TextView
+                    android:id="@+id/textview_mimetype"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"/>
+
+        </LinearLayout>
+    </LinearLayout>
+</RelativeLayout>
diff --git a/content/documentsUi/DirectorySelection/Application/src/main/res/layout/fragment_directory_selection.xml b/content/documentsUi/DirectorySelection/Application/src/main/res/layout/fragment_directory_selection.xml
new file mode 100644
index 0000000..d63219c
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/src/main/res/layout/fragment_directory_selection.xml
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+              android:gravity="center_vertical"
+              android:layout_width="match_parent"
+              android:layout_height="match_parent"
+              android:orientation="vertical"
+              android:padding="@dimen/margin_medium">
+
+    <LinearLayout android:layout_width="wrap_content"
+                  android:layout_height="wrap_content"
+                  android:orientation="horizontal"
+            >
+
+        <Button android:id="@+id/button_open_directory"
+                android:text="@string/open_directory"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"/>
+
+        <Button android:id="@+id/button_create_directory"
+                android:text="@string/create_directory"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:enabled="false"
+                />
+    </LinearLayout>
+
+    <LinearLayout android:layout_width="wrap_content"
+                  android:layout_height="wrap_content"
+                  android:orientation="horizontal"
+                  android:layout_marginLeft="@dimen/margin_small"
+                  android:layout_marginRight="@dimen/margin_small"
+            >
+
+        <TextView android:id="@+id/label_current_directory"
+                  android:text="@string/selected_directory"
+                  android:layout_width="wrap_content"
+                  android:layout_height="wrap_content"/>
+
+        <TextView android:id="@+id/textview_current_directory"
+                  android:enabled="false"
+                  android:layout_width="wrap_content"
+                  android:layout_height="wrap_content"
+                  style="@style/DirectoryEntryNameFont"
+                />
+
+    </LinearLayout>
+
+    <android.support.v7.widget.RecyclerView
+            android:id="@+id/recyclerview_directory_entries"
+            android:layout_marginLeft="@dimen/margin_small"
+            android:layout_marginRight="@dimen/margin_small"
+            android:scrollbars="vertical"
+            android:drawSelectorOnTop="true"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"/>
+
+</LinearLayout>
+
diff --git a/content/documentsUi/DirectorySelection/Application/src/main/res/menu/main.xml b/content/documentsUi/DirectorySelection/Application/src/main/res/menu/main.xml
new file mode 100644
index 0000000..e9b5e0b
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/src/main/res/menu/main.xml
@@ -0,0 +1,16 @@
+<!--
+  Copyright 2014 The Android Open Source Project
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+  -->
+<menu xmlns:android="http://schemas.android.com/apk/res/android" />
diff --git a/content/documentsUi/DirectorySelection/Application/src/main/res/values/dimens.xml b/content/documentsUi/DirectorySelection/Application/src/main/res/values/dimens.xml
new file mode 100644
index 0000000..53d0182
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/src/main/res/values/dimens.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<resources>
+    <dimen name="directory_item_height">72dp</dimen>
+</resources>
\ No newline at end of file
diff --git a/content/documentsUi/DirectorySelection/Application/src/main/res/values/strings.xml b/content/documentsUi/DirectorySelection/Application/src/main/res/values/strings.xml
new file mode 100644
index 0000000..24d59dd
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/src/main/res/values/strings.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<resources>
+    <string name="open_directory">Open directory</string>
+    <string name="create_directory">Create Directory</string>
+    <string name="selected_directory">"Selected Directory : "</string>
+</resources>
diff --git a/content/documentsUi/DirectorySelection/Application/src/main/res/values/styles.xml b/content/documentsUi/DirectorySelection/Application/src/main/res/values/styles.xml
new file mode 100644
index 0000000..38441f3
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/src/main/res/values/styles.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<resources>
+    <style name="DirectoryEntryNameFont" parent="@android:style/TextAppearance.Medium">
+        <item name="android:textColor">#000000</item>
+    </style>
+</resources>
\ No newline at end of file
diff --git a/content/documentsUi/DirectorySelection/Application/tests/src/com/example/android/directoryselection/DirectoryEntryAdapterTest.java b/content/documentsUi/DirectorySelection/Application/tests/src/com/example/android/directoryselection/DirectoryEntryAdapterTest.java
new file mode 100644
index 0000000..97b2629
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/tests/src/com/example/android/directoryselection/DirectoryEntryAdapterTest.java
@@ -0,0 +1,82 @@
+/*
+* Copyright 2014 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+/*
+* Copyright (C) 2014 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package com.example.android.directoryselection;
+
+import android.test.ActivityInstrumentationTestCase2;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Tests for {@link DirectorySelectionFragment}.
+ */
+public class DirectoryEntryAdapterTest
+        extends ActivityInstrumentationTestCase2<DirectorySelectionActivity> {
+
+    private static final String FILE1 = "file1";
+    private static final String MIME_TYPE1 = "text/appliaction";
+    private static final String DIRECTORY1 = "directory1";
+
+    private DirectorySelectionActivity mTestActivity;
+    private DirectorySelectionFragment mTestFragment;
+    private DirectoryEntryAdapter mAdapter;
+    private List<DirectoryEntry> mDirectoryEntries;
+
+    public DirectoryEntryAdapterTest() {
+        super(DirectorySelectionActivity.class);
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        mTestActivity = getActivity();
+        mTestFragment = (DirectorySelectionFragment)
+                mTestActivity.getSupportFragmentManager().getFragments().get(0);
+        mDirectoryEntries = new ArrayList<>();
+
+        DirectoryEntry file = new DirectoryEntry();
+        file.fileName = FILE1;
+        file.mimeType = MIME_TYPE1;
+        mDirectoryEntries.add(file);
+
+        DirectoryEntry directory = new DirectoryEntry();
+        directory.fileName = DIRECTORY1;
+        directory.mimeType = DirectoryEntryAdapter.DIRECTORY_MIME_TYPE;
+        mDirectoryEntries.add(directory);
+    }
+
+    public void testGetItemCount() {
+        mTestFragment.mAdapter.setDirectoryEntries(mDirectoryEntries);
+
+        assertEquals(2, mTestFragment.mAdapter.getItemCount());
+    }
+}
diff --git a/content/documentsUi/DirectorySelection/Application/tests/src/com/example/android/directoryselection/DirectorySelectionActivityTest.java b/content/documentsUi/DirectorySelection/Application/tests/src/com/example/android/directoryselection/DirectorySelectionActivityTest.java
new file mode 100644
index 0000000..8f767ae
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/tests/src/com/example/android/directoryselection/DirectorySelectionActivityTest.java
@@ -0,0 +1,56 @@
+/*
+* Copyright 2014 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package com.example.android.directoryselection;
+
+import android.test.ActivityInstrumentationTestCase2;
+
+/**
+ * Tests for {@link DirectorySelectionActivity}.
+ */
+public class DirectorySelectionActivityTest
+        extends ActivityInstrumentationTestCase2<DirectorySelectionActivity> {
+
+    private DirectorySelectionActivity mTestActivity;
+    private DirectorySelectionFragment mTestFragment;
+
+    public DirectorySelectionActivityTest() {
+        super(DirectorySelectionActivity.class);
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        // Starts the activity under test using the default Intent with:
+        // action = {@link Intent#ACTION_MAIN}
+        // flags = {@link Intent#FLAG_ACTIVITY_NEW_TASK}
+        // All other fields are null or empty.
+        mTestActivity = getActivity();
+        mTestFragment = (DirectorySelectionFragment)
+                mTestActivity.getSupportFragmentManager().getFragments().get(0);
+    }
+
+    /**
+     * Test if the test fixture has been set up correctly.
+     */
+    public void testPreconditions() {
+        //Try to add a message to add context to your assertions. These messages will be shown if
+        //a tests fails and make it easy to understand why a test failed
+        assertNotNull("mTestActivity is null", mTestActivity);
+        assertNotNull("mTestFragment is null", mTestFragment);
+    }
+}
diff --git a/content/documentsUi/DirectorySelection/Application/tests/src/com/example/android/directoryselection/DirectorySelectionFragmentTest.java b/content/documentsUi/DirectorySelection/Application/tests/src/com/example/android/directoryselection/DirectorySelectionFragmentTest.java
new file mode 100644
index 0000000..90cd30f
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/Application/tests/src/com/example/android/directoryselection/DirectorySelectionFragmentTest.java
@@ -0,0 +1,68 @@
+/*
+* Copyright 2014 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+/*
+* Copyright (C) 2014 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package com.example.android.directoryselection;
+
+import android.test.ActivityInstrumentationTestCase2;
+
+/**
+ * Tests for {@link com.example.android.directoryselection.DirectorySelectionFragment}.
+ */
+public class DirectorySelectionFragmentTest
+        extends ActivityInstrumentationTestCase2<DirectorySelectionActivity> {
+
+    private DirectorySelectionActivity mTestActivity;
+    private DirectorySelectionFragment mTestFragment;
+
+    public DirectorySelectionFragmentTest() {
+        super(DirectorySelectionActivity.class);
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        // Starts the activity under test using the default Intent with:
+        // action = {@link Intent#ACTION_MAIN}
+        // flags = {@link Intent#FLAG_ACTIVITY_NEW_TASK}
+        // All other fields are null or empty.
+        mTestActivity = getActivity();
+        mTestFragment = (DirectorySelectionFragment)
+                mTestActivity.getSupportFragmentManager().getFragments().get(0);
+    }
+
+    public void testPreconditions() {
+        assertNotNull(mTestFragment.mCurrentDirectoryTextView);
+        assertNotNull(mTestFragment.mCreateDirectoryButton);
+        assertNotNull(mTestFragment.mRecyclerView);
+        assertNotNull(mTestFragment.mAdapter);
+        assertNotNull(mTestFragment.mLayoutManager);
+    }
+}
diff --git a/content/documentsUi/DirectorySelection/build.gradle b/content/documentsUi/DirectorySelection/build.gradle
new file mode 100644
index 0000000..18f393f
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/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/content/documentsUi/DirectorySelection/buildSrc/build.gradle b/content/documentsUi/DirectorySelection/buildSrc/build.gradle
new file mode 100644
index 0000000..7cebf71
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/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/content/documentsUi/DirectorySelection/gradle/wrapper/gradle-wrapper.jar b/content/documentsUi/DirectorySelection/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..8c0fb64
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/content/documentsUi/DirectorySelection/gradle/wrapper/gradle-wrapper.properties b/content/documentsUi/DirectorySelection/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..3e37868
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Wed Dec 03 14:12:05 JST 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/content/documentsUi/DirectorySelection/gradlew b/content/documentsUi/DirectorySelection/gradlew
new file mode 100755
index 0000000..91a7e26
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/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/content/documentsUi/DirectorySelection/gradlew.bat b/content/documentsUi/DirectorySelection/gradlew.bat
new file mode 100644
index 0000000..aec9973
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/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/content/documentsUi/DirectorySelection/screenshots/screenshot-1.png b/content/documentsUi/DirectorySelection/screenshots/screenshot-1.png
new file mode 100644
index 0000000..a4310dc
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/screenshots/screenshot-1.png
Binary files differ
diff --git a/content/documentsUi/DirectorySelection/screenshots/screenshot-2.png b/content/documentsUi/DirectorySelection/screenshots/screenshot-2.png
new file mode 100644
index 0000000..cd27507
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/screenshots/screenshot-2.png
Binary files differ
diff --git a/content/documentsUi/DirectorySelection/screenshots/screenshot-3.png b/content/documentsUi/DirectorySelection/screenshots/screenshot-3.png
new file mode 100644
index 0000000..0795475
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/screenshots/screenshot-3.png
Binary files differ
diff --git a/content/documentsUi/DirectorySelection/screenshots/web-icon.png b/content/documentsUi/DirectorySelection/screenshots/web-icon.png
new file mode 100755
index 0000000..f0a573f
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/screenshots/web-icon.png
Binary files differ
diff --git a/content/documentsUi/DirectorySelection/settings.gradle b/content/documentsUi/DirectorySelection/settings.gradle
new file mode 100644
index 0000000..9464a35
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/settings.gradle
@@ -0,0 +1 @@
+include 'Application'
diff --git a/content/documentsUi/DirectorySelection/template-params.xml b/content/documentsUi/DirectorySelection/template-params.xml
new file mode 100644
index 0000000..c0172f6
--- /dev/null
+++ b/content/documentsUi/DirectorySelection/template-params.xml
@@ -0,0 +1,163 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<sample>
+    <name>DirectorySelection</name>
+    <group>Content</group>
+    <package>com.example.android.directoryselection</package>
+
+    <dependency>com.android.support:recyclerview-v7:+</dependency>
+
+    <!-- change minSdk if needed-->
+    <minSdk>21</minSdk>
+
+    <strings>
+        <intro>
+            <![CDATA[
+            This sample explains how to use Directory selection API, which was introduced
+            in Android 5.0.
+            ]]>
+        </intro>
+    </strings>
+
+    <template src="base" />
+
+    <metadata>
+        <status>DRAFTED</status>
+        <categories>Content</categories>
+        <technologies>Android</technologies>
+        <languages>Java</languages>
+        <solutions>Mobile</solutions>
+        <level>INTERMEDIATE</level>
+        <icon>screenshots/web-icon.png</icon>
+        <screenshots>
+            <img>screenshots/screenshot-1.png</img>
+            <img>screenshots/screenshot-2.png</img>
+            <img>screenshots/screenshot-3.png</img>
+        </screenshots>
+        <api_refs>
+            <android>android.content.ContentResolver</android>
+            <android>android.provider.DocumentsContract</android>
+        </api_refs>
+
+        <description>
+<![CDATA[
+A basic app showing how to use Directory Selection API to let users
+select an entire directory subtree, which extends the Storage Access Framework
+introduced in Android 4.4 (API level 19).
+]]>
+        </description>
+
+        <intro>
+<![CDATA[
+The [Directory Selection][1] API, which was introduced in Android 5.0 (API level 21)
+extends the [Storage Access Framework][2] to let users select an entire directory subtree,
+giving apps read/write access to all contained documents without requiring user
+confirmation for each item.
+
+To select a directory subtree, build and send an [OPEN_DOCUMENT_TREE intent][3] like in the
+following code:
+
+```java
+Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
+startActivityForResult(intent, REQUEST_CODE_OPEN_DIRECTORY);
+```
+
+The system displays all [DocumentsProvider][4] instances that support subtree selection,
+ letting the user browse and select a directory.
+
+The returned URI represents access to the selected subtree. You can then use
+[buildChildDocumentsUriUsingTree()][5] to access to the child documents and
+[buildDocumentUriUsingTree()][6] to access to the selected directory itself along with [query()][7]
+to explore the subtree.
+
+This example explores the child documents and the selected document by following code:
+
+```java
+@Override
+public void onActivityResult(int requestCode, int resultCode, Intent data) {
+    super.onActivityResult(requestCode, resultCode, data);
+    if (requestCode == REQUEST_CODE_OPEN_DIRECTORY && resultCode == Activity.RESULT_OK) {
+        updateDirectoryEntries(data.getData());
+    }
+}
+
+void updateDirectoryEntries(Uri uri) {
+    ContentResolver contentResolver = getActivity().getContentResolver();
+    Uri docUri = DocumentsContract.buildDocumentUriUsingTree(uri,
+            DocumentsContract.getTreeDocumentId(uri));
+    Uri childrenUri = DocumentsContract.buildChildDocumentsUriUsingTree(uri,
+            DocumentsContract.getTreeDocumentId(uri));
+
+    Cursor docCursor = contentResolver.query(docUri, new String[]{
+            Document.COLUMN_DISPLAY_NAME, Document.COLUMN_MIME_TYPE}, null, null, null);
+    try {
+        while (docCursor.moveToNext()) {
+            Log.d(TAG, "found doc =" + docCursor.getString(0) + ", mime=" + docCursor
+                    .getString(1));
+            mCurrentDirectoryUri = uri;
+            mCurrentDirectoryTextView.setText(docCursor.getString(0));
+            mCreateDirectoryButton.setEnabled(true);
+        }
+    } finally {
+        closeQuietly(docCursor);
+    }
+
+    Cursor childCursor = contentResolver.query(childrenUri, new String[]{
+            Document.COLUMN_DISPLAY_NAME, Document.COLUMN_MIME_TYPE}, null, null, null);
+    try {
+        List<DirectoryEntry> directoryEntries = new ArrayList<>();
+        while (childCursor.moveToNext()) {
+            Log.d(TAG, "found child=" + childCursor.getString(0) + ", mime=" + childCursor
+                    .getString(1));
+            DirectoryEntry entry = new DirectoryEntry();
+            entry.fileName = childCursor.getString(0);
+            entry.mimeType = childCursor.getString(1);
+            directoryEntries.add(entry);
+        }
+        mAdapter.setDirectoryEntries(directoryEntries);
+        mAdapter.notifyDataSetChanged();
+    } finally {
+        closeQuietly(childCursor);
+    }
+}
+```
+
+Also, the new [createDocument()][8] method lets you create new documents or directories
+anywhere under the subtree.
+
+This example creates a new directory by following code:
+
+```java
+ContentResolver contentResolver = getActivity().getContentResolver();
+Uri docUri = DocumentsContract.buildDocumentUriUsingTree(uri,
+        DocumentsContract.getTreeDocumentId(uri));
+Uri directoryUri = DocumentsContract
+        .createDocument(contentResolver, docUri, Document.MIME_TYPE_DIR, directoryName);
+```
+
+[1]: https://developer.android.com/about/versions/android-5.0.html#Storage
+[2]: https://developer.android.com/guide/topics/providers/document-provider.html
+[3]: https://developer.android.com/reference/android/content/Intent.html#ACTION_OPEN_DOCUMENT_TREE
+[4]: https://developer.android.com/reference/android/provider/DocumentsProvider.html
+[5]: https://developer.android.com/reference/android/provider/DocumentsContract.html#buildChildDocumentsUriUsingTree(android.net.Uri%2C%20java.lang.String)
+[6]: https://developer.android.com/reference/android/provider/DocumentsContract.html#buildDocumentUriUsingTree(android.net.Uri%2C%20java.lang.String)
+[7]: https://developer.android.com/reference/android/content/ContentResolver.html#query(android.net.Uri%2C%20java.lang.String%5B%5D%2C%20java.lang.String%2C%20java.lang.String%5B%5D%2C%20java.lang.String)
+[8]: https://developer.android.com/reference/android/provider/DocumentsContract.html#createDocument(android.content.ContentResolver%2C%20android.net.Uri%2C%20java.lang.String%2C%20java.lang.String)
+]]>
+        </intro>
+    </metadata>
+</sample>
diff --git a/content/webview/PermissionRequest/Application/.gitignore b/content/webview/PermissionRequest/Application/.gitignore
new file mode 100644
index 0000000..6eb878d
--- /dev/null
+++ b/content/webview/PermissionRequest/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/content/webview/PermissionRequest/Application/README-fragmentview.txt b/content/webview/PermissionRequest/Application/README-fragmentview.txt
new file mode 100644
index 0000000..38d903f
--- /dev/null
+++ b/content/webview/PermissionRequest/Application/README-fragmentview.txt
@@ -0,0 +1,37 @@
+<!--
+        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.
+-->
+
+Steps to implement FragmentView template:
+-in template-params.xml.ftl:
+    -add the following line to common imports
+        <common src="activities"/>
+
+-Add a Fragment to show behavior.  In your MainActivity.java class, it will reference a Fragment
+ called (yourProjectName)Fragment.java.  Create that file in your project, using the "main" source
+ folder instead of "common" or "templates".
+   For instance, if your package name is com.example.foo, create the file
+   src/main/java/com/example/foo/FooFragment.java
+
+
+-Within this fragment, make sure that the onCreate method has the line
+ "setHasOptionsMenu(true);", to enable the fragment to handle menu events.
+
+-In order to override menu events, override onOptionsItemSelected.
+
+-refer to sampleSamples/fragmentViewSample for a reference implementation of a
+project built on this template.
+
+
diff --git a/content/webview/PermissionRequest/Application/README-singleview.txt b/content/webview/PermissionRequest/Application/README-singleview.txt
new file mode 100644
index 0000000..0cacd46
--- /dev/null
+++ b/content/webview/PermissionRequest/Application/README-singleview.txt
@@ -0,0 +1,47 @@
+<#--
+        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.
+-->
+
+Steps to implement SingleView template:
+-in template-params.xml.ftl:
+    -add the following line to common imports
+        <common src="activities"/>
+
+    -add a string for the action button's text using the element name "sample_action".
+    This element should be a child of <strings>:
+        <strings>
+        ...
+        <sample_action>ButtonText</sample_action>
+        ...
+        </strings>
+
+
+
+-Add a Fragment to handle behavior.  In your MainActivity.java class, it will reference a Fragment
+ called (yourProjectName)Fragment.java.  Create that file in your project, using the "main" source
+ folder instead of "common" or "templates".
+   For instance, if your package name is com.example.foo, create the file
+   src/main/java/com/example/foo/FooFragment.java
+
+
+-Within this fragment, make sure that the onCreate method has the line
+ "setHasOptionsMenu(true);", to enable the fragment to handle menu events.
+
+-In order to override menu events, override onOptionsItemSelected.
+
+-refer to sampleSamples/singleViewSample for a reference implementation of a
+project built on this template.
+
+
diff --git a/content/webview/PermissionRequest/Application/proguard-project.txt b/content/webview/PermissionRequest/Application/proguard-project.txt
new file mode 100644
index 0000000..0d8f171
--- /dev/null
+++ b/content/webview/PermissionRequest/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/content/webview/PermissionRequest/Application/src/main/AndroidManifest.xml b/content/webview/PermissionRequest/Application/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..f8fd050
--- /dev/null
+++ b/content/webview/PermissionRequest/Application/src/main/AndroidManifest.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.example.android.permissionrequest"
+    android:versionCode="1"
+    android:versionName="1.0">
+
+    <uses-permission android:name="android.permission.INTERNET"/>
+    <uses-permission android:name="android.permission.CAMERA"/>
+
+    <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/content/webview/PermissionRequest/Application/src/main/assets/sample.css b/content/webview/PermissionRequest/Application/src/main/assets/sample.css
new file mode 100644
index 0000000..9d1364c
--- /dev/null
+++ b/content/webview/PermissionRequest/Application/src/main/assets/sample.css
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+body {
+    text-align: center;
+}
+
+div {
+    margin-bottom: 8px;
+}
+
+button {
+    height: 48px;
+    width: 80px;
+    font-weight: bold;
+    font-size: 14pt;
+}
+
+video {
+    width: 240px;
+    height: 180px;
+    transform: scaleX(-1); /* Mirror */
+}
diff --git a/content/webview/PermissionRequest/Application/src/main/assets/sample.html b/content/webview/PermissionRequest/Application/src/main/assets/sample.html
new file mode 100644
index 0000000..a9729a3
--- /dev/null
+++ b/content/webview/PermissionRequest/Application/src/main/assets/sample.html
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<!--
+  Copyright 2014 The Android Open Source Project
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<html>
+<head>
+    <title>sample</title>
+    <link rel="stylesheet" href="sample.css">
+</head>
+<body>
+
+<div>
+    <button id="toggle">Start</button>
+</div>
+<video id="video" autoplay></video>
+
+<script src="sample.js"></script>
+</body>
+</html>
diff --git a/content/webview/PermissionRequest/Application/src/main/assets/sample.js b/content/webview/PermissionRequest/Application/src/main/assets/sample.js
new file mode 100644
index 0000000..e2806a0
--- /dev/null
+++ b/content/webview/PermissionRequest/Application/src/main/assets/sample.js
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+(function () {
+    "use strict";
+
+    navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia;
+    window.URL = window.URL || window.webkitURL;
+
+    window.onload = function () {
+
+        var video = document.querySelector('#video'),
+            toggle = document.querySelector('#toggle'),
+            stream = null;
+
+        if (!navigator.getUserMedia) {
+            console.error('getUserMedia not supported');
+        }
+
+        toggle.addEventListener('click', function () {
+            if (null === stream) {
+                // This call to "getUserMedia" initiates a PermissionRequest in the WebView.
+                navigator.getUserMedia({ video: true }, function (s) {
+                    stream = s;
+                    video.src = window.URL.createObjectURL(stream);
+                    toggle.innerText = 'Stop';
+                    console.log('Started');
+                }, function (error) {
+                    console.error('Error starting camera. Denied.');
+                });
+            } else {
+                stream.stop();
+                stream = null;
+                toggle.innerText = 'Start';
+                console.log('Stopped');
+            }
+        });
+
+        console.log('Page loaded');
+
+    };
+
+})();
diff --git a/content/webview/PermissionRequest/Application/src/main/java/com/example/android/permissionrequest/ConfirmationDialogFragment.java b/content/webview/PermissionRequest/Application/src/main/java/com/example/android/permissionrequest/ConfirmationDialogFragment.java
new file mode 100644
index 0000000..7dae56e
--- /dev/null
+++ b/content/webview/PermissionRequest/Application/src/main/java/com/example/android/permissionrequest/ConfirmationDialogFragment.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.example.android.permissionrequest;
+
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.content.DialogInterface;
+import android.os.Bundle;
+import android.support.v4.app.DialogFragment;
+import android.text.TextUtils;
+
+/**
+ * Prompts the user to confirm permission request.
+ */
+public class ConfirmationDialogFragment extends DialogFragment {
+
+    private static final String ARG_RESOURCES = "resources";
+
+    /**
+     * Creates a new instance of ConfirmationDialogFragment.
+     *
+     * @param resources The list of resources requested by PermissionRequeste.
+     * @return A new instance.
+     */
+    public static ConfirmationDialogFragment newInstance(String[] resources) {
+        ConfirmationDialogFragment fragment = new ConfirmationDialogFragment();
+        Bundle args = new Bundle();
+        args.putStringArray(ARG_RESOURCES, resources);
+        fragment.setArguments(args);
+        return fragment;
+    }
+
+    @Override
+    public Dialog onCreateDialog(Bundle savedInstanceState) {
+        String[] resources = getArguments().getStringArray(ARG_RESOURCES);
+        return new AlertDialog.Builder(getActivity())
+                .setMessage(getString(R.string.confirmation, TextUtils.join("\n", resources)))
+                .setNegativeButton(R.string.deny, new DialogInterface.OnClickListener() {
+                    @Override
+                    public void onClick(DialogInterface dialog, int which) {
+                        ((Listener) getParentFragment()).onConfirmation(false);
+                    }
+                })
+                .setPositiveButton(R.string.allow, new DialogInterface.OnClickListener() {
+                    @Override
+                    public void onClick(DialogInterface dialog, int which) {
+                        ((Listener) getParentFragment()).onConfirmation(true);
+                    }
+                })
+                .create();
+    }
+
+    /**
+     * Callback for the user's response.
+     */
+    public interface Listener {
+
+        /**
+         * Called when the PermissoinRequest is allowed or denied by the user.
+         *
+         * @param allowed True if the user allowed the request.
+         */
+        public void onConfirmation(boolean allowed);
+    }
+
+}
diff --git a/content/webview/PermissionRequest/Application/src/main/java/com/example/android/permissionrequest/PermissionRequestFragment.java b/content/webview/PermissionRequest/Application/src/main/java/com/example/android/permissionrequest/PermissionRequestFragment.java
new file mode 100644
index 0000000..44f1d6e
--- /dev/null
+++ b/content/webview/PermissionRequest/Application/src/main/java/com/example/android/permissionrequest/PermissionRequestFragment.java
@@ -0,0 +1,180 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.android.permissionrequest;
+
+import android.annotation.SuppressLint;
+import android.os.Bundle;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
+import android.support.v4.app.DialogFragment;
+import android.support.v4.app.Fragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.webkit.ConsoleMessage;
+import android.webkit.PermissionRequest;
+import android.webkit.WebChromeClient;
+import android.webkit.WebSettings;
+import android.webkit.WebView;
+
+import com.example.android.common.logger.Log;
+
+/**
+ * This fragment shows a {@link WebView} and loads a web app from the {@link SimpleWebServer}.
+ */
+public class PermissionRequestFragment extends Fragment
+        implements ConfirmationDialogFragment.Listener {
+
+    private static final String TAG = PermissionRequestFragment.class.getSimpleName();
+
+    private static final String FRAGMENT_DIALOG = "dialog";
+
+    /**
+     * We use this web server to serve HTML files in the assets folder. This is because we cannot
+     * use the JavaScript method "getUserMedia" from "file:///android_assets/..." URLs.
+     */
+    private SimpleWebServer mWebServer;
+
+    /**
+     * A reference to the {@link WebView}.
+     */
+    private WebView mWebView;
+
+    /**
+     * This field stores the {@link PermissionRequest} from the web application until it is allowed
+     * or denied by user.
+     */
+    private PermissionRequest mPermissionRequest;
+
+    /**
+     * For testing.
+     */
+    private ConsoleMonitor mConsoleMonitor;
+
+    @Override
+    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
+                             @Nullable Bundle savedInstanceState) {
+        return inflater.inflate(R.layout.fragment_permission_request, container, false);
+    }
+
+    @Override
+    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
+        mWebView = (WebView) view.findViewById(R.id.web_view);
+        // Here, we use #mWebChromeClient with implementation for handling PermissionRequests.
+        mWebView.setWebChromeClient(mWebChromeClient);
+        configureWebSettings(mWebView.getSettings());
+    }
+
+    @Override
+    public void onResume() {
+        super.onResume();
+        final int port = 8080;
+        mWebServer = new SimpleWebServer(port, getResources().getAssets());
+        mWebServer.start();
+        mWebView.loadUrl("http://localhost:" + port + "/sample.html");
+    }
+
+    @Override
+    public void onPause() {
+        mWebServer.stop();
+        super.onPause();
+    }
+
+    @SuppressLint("SetJavaScriptEnabled")
+    private static void configureWebSettings(WebSettings settings) {
+        settings.setJavaScriptEnabled(true);
+    }
+
+    /**
+     * This {@link WebChromeClient} has implementation for handling {@link PermissionRequest}.
+     */
+    private WebChromeClient mWebChromeClient = new WebChromeClient() {
+
+        // This method is called when the web content is requesting permission to access some
+        // resources.
+        @Override
+        public void onPermissionRequest(PermissionRequest request) {
+            Log.i(TAG, "onPermissionRequest");
+            mPermissionRequest = request;
+            ConfirmationDialogFragment.newInstance(request.getResources())
+                    .show(getChildFragmentManager(), FRAGMENT_DIALOG);
+        }
+
+        // This method is called when the permission request is canceled by the web content.
+        @Override
+        public void onPermissionRequestCanceled(PermissionRequest request) {
+            Log.i(TAG, "onPermissionRequestCanceled");
+            // We dismiss the prompt UI here as the request is no longer valid.
+            mPermissionRequest = null;
+            DialogFragment fragment = (DialogFragment) getChildFragmentManager()
+                    .findFragmentByTag(FRAGMENT_DIALOG);
+            if (null != fragment) {
+                fragment.dismiss();
+            }
+        }
+
+        @Override
+        public boolean onConsoleMessage(@NonNull ConsoleMessage message) {
+            switch (message.messageLevel()) {
+                case TIP:
+                    Log.v(TAG, message.message());
+                    break;
+                case LOG:
+                    Log.i(TAG, message.message());
+                    break;
+                case WARNING:
+                    Log.w(TAG, message.message());
+                    break;
+                case ERROR:
+                    Log.e(TAG, message.message());
+                    break;
+                case DEBUG:
+                    Log.d(TAG, message.message());
+                    break;
+            }
+            if (null != mConsoleMonitor) {
+                mConsoleMonitor.onConsoleMessage(message);
+            }
+            return true;
+        }
+
+    };
+
+    @Override
+    public void onConfirmation(boolean allowed) {
+        if (allowed) {
+            mPermissionRequest.grant(mPermissionRequest.getResources());
+            Log.d(TAG, "Permission granted.");
+        } else {
+            mPermissionRequest.deny();
+            Log.d(TAG, "Permission request denied.");
+        }
+        mPermissionRequest = null;
+    }
+
+    public void setConsoleMonitor(ConsoleMonitor monitor) {
+        mConsoleMonitor = monitor;
+    }
+
+    /**
+     * For testing.
+     */
+    public interface ConsoleMonitor {
+        public void onConsoleMessage(ConsoleMessage message);
+    }
+
+}
diff --git a/content/webview/PermissionRequest/Application/src/main/java/com/example/android/permissionrequest/SimpleWebServer.java b/content/webview/PermissionRequest/Application/src/main/java/com/example/android/permissionrequest/SimpleWebServer.java
new file mode 100644
index 0000000..36b7c46
--- /dev/null
+++ b/content/webview/PermissionRequest/Application/src/main/java/com/example/android/permissionrequest/SimpleWebServer.java
@@ -0,0 +1,222 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.example.android.permissionrequest;
+
+import android.content.res.AssetManager;
+import android.text.TextUtils;
+import android.util.Log;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayOutputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.PrintStream;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.net.SocketException;
+
+/**
+ * Implementation of a very basic HTTP server. The contents are loaded from the assets folder. This
+ * server handles one request at a time. It only supports GET method.
+ */
+public class SimpleWebServer implements Runnable {
+
+    private static final String TAG = "SimpleWebServer";
+
+    /**
+     * The port number we listen to
+     */
+    private final int mPort;
+
+    /**
+     * {@link android.content.res.AssetManager} for loading files to serve.
+     */
+    private final AssetManager mAssets;
+
+    /**
+     * True if the server is running.
+     */
+    private boolean mIsRunning;
+
+    /**
+     * The {@link java.net.ServerSocket} that we listen to.
+     */
+    private ServerSocket mServerSocket;
+
+    /**
+     * WebServer constructor.
+     */
+    public SimpleWebServer(int port, AssetManager assets) {
+        mPort = port;
+        mAssets = assets;
+    }
+
+    /**
+     * This method starts the web server listening to the specified port.
+     */
+    public void start() {
+        mIsRunning = true;
+        new Thread(this).start();
+    }
+
+    /**
+     * This method stops the web server
+     */
+    public void stop() {
+        try {
+            mIsRunning = false;
+            if (null != mServerSocket) {
+                mServerSocket.close();
+                mServerSocket = null;
+            }
+        } catch (IOException e) {
+            Log.e(TAG, "Error closing the server socket.", e);
+        }
+    }
+
+    @Override
+    public void run() {
+        try {
+            mServerSocket = new ServerSocket(mPort);
+            while (mIsRunning) {
+                Socket socket = mServerSocket.accept();
+                handle(socket);
+                socket.close();
+            }
+        } catch (SocketException e) {
+            // The server was stopped; ignore.
+        } catch (IOException e) {
+            Log.e(TAG, "Web server error.", e);
+        }
+    }
+
+    /**
+     * Respond to a request from a client.
+     *
+     * @param socket The client socket.
+     * @throws IOException
+     */
+    private void handle(Socket socket) throws IOException {
+        BufferedReader reader = null;
+        PrintStream output = null;
+        try {
+            String route = null;
+
+            // Read HTTP headers and parse out the route.
+            reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
+            String line;
+            while (!TextUtils.isEmpty(line = reader.readLine())) {
+                if (line.startsWith("GET /")) {
+                    int start = line.indexOf('/') + 1;
+                    int end = line.indexOf(' ', start);
+                    route = line.substring(start, end);
+                    break;
+                }
+            }
+
+            // Output stream that we send the response to
+            output = new PrintStream(socket.getOutputStream());
+
+            // Prepare the content to send.
+            if (null == route) {
+                writeServerError(output);
+                return;
+            }
+            byte[] bytes = loadContent(route);
+            if (null == bytes) {
+                writeServerError(output);
+                return;
+            }
+
+            // Send out the content.
+            output.println("HTTP/1.0 200 OK");
+            output.println("Content-Type: " + detectMimeType(route));
+            output.println("Content-Length: " + bytes.length);
+            output.println();
+            output.write(bytes);
+            output.flush();
+        } finally {
+            if (null != output) {
+                output.close();
+            }
+            if (null != reader) {
+                reader.close();
+            }
+        }
+    }
+
+    /**
+     * Writes a server error response (HTTP/1.0 500) to the given output stream.
+     *
+     * @param output The output stream.
+     */
+    private void writeServerError(PrintStream output) {
+        output.println("HTTP/1.0 500 Internal Server Error");
+        output.flush();
+    }
+
+    /**
+     * Loads all the content of {@code fileName}.
+     *
+     * @param fileName The name of the file.
+     * @return The content of the file.
+     * @throws IOException
+     */
+    private byte[] loadContent(String fileName) throws IOException {
+        InputStream input = null;
+        try {
+            ByteArrayOutputStream output = new ByteArrayOutputStream();
+            input = mAssets.open(fileName);
+            byte[] buffer = new byte[1024];
+            int size;
+            while (-1 != (size = input.read(buffer))) {
+                output.write(buffer, 0, size);
+            }
+            output.flush();
+            return output.toByteArray();
+        } catch (FileNotFoundException e) {
+            return null;
+        } finally {
+            if (null != input) {
+                input.close();
+            }
+        }
+    }
+
+    /**
+     * Detects the MIME type from the {@code fileName}.
+     *
+     * @param fileName The name of the file.
+     * @return A MIME type.
+     */
+    private String detectMimeType(String fileName) {
+        if (TextUtils.isEmpty(fileName)) {
+            return null;
+        } else if (fileName.endsWith(".html")) {
+            return "text/html";
+        } else if (fileName.endsWith(".js")) {
+            return "application/javascript";
+        } else if (fileName.endsWith(".css")) {
+            return "text/css";
+        } else {
+            return "application/octet-stream";
+        }
+    }
+
+}
diff --git a/content/webview/PermissionRequest/Application/src/main/res/drawable-hdpi/ic_launcher.png b/content/webview/PermissionRequest/Application/src/main/res/drawable-hdpi/ic_launcher.png
new file mode 100644
index 0000000..4dae25b
--- /dev/null
+++ b/content/webview/PermissionRequest/Application/src/main/res/drawable-hdpi/ic_launcher.png
Binary files differ
diff --git a/content/webview/PermissionRequest/Application/src/main/res/drawable-mdpi/ic_launcher.png b/content/webview/PermissionRequest/Application/src/main/res/drawable-mdpi/ic_launcher.png
new file mode 100644
index 0000000..e896d49
--- /dev/null
+++ b/content/webview/PermissionRequest/Application/src/main/res/drawable-mdpi/ic_launcher.png
Binary files differ
diff --git a/content/webview/PermissionRequest/Application/src/main/res/drawable-xhdpi/ic_launcher.png b/content/webview/PermissionRequest/Application/src/main/res/drawable-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..5309f55
--- /dev/null
+++ b/content/webview/PermissionRequest/Application/src/main/res/drawable-xhdpi/ic_launcher.png
Binary files differ
diff --git a/content/webview/PermissionRequest/Application/src/main/res/drawable-xxhdpi/ic_launcher.png b/content/webview/PermissionRequest/Application/src/main/res/drawable-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..61b137b
--- /dev/null
+++ b/content/webview/PermissionRequest/Application/src/main/res/drawable-xxhdpi/ic_launcher.png
Binary files differ
diff --git a/content/webview/PermissionRequest/Application/src/main/res/layout/fragment_permission_request.xml b/content/webview/PermissionRequest/Application/src/main/res/layout/fragment_permission_request.xml
new file mode 100644
index 0000000..2e97a0a
--- /dev/null
+++ b/content/webview/PermissionRequest/Application/src/main/res/layout/fragment_permission_request.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+              android:layout_width="match_parent"
+              android:layout_height="match_parent"
+              android:orientation="vertical">
+
+    <WebView
+        android:id="@+id/web_view"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"/>
+
+</LinearLayout>
diff --git a/content/webview/PermissionRequest/Application/src/main/res/values/strings.xml b/content/webview/PermissionRequest/Application/src/main/res/values/strings.xml
new file mode 100644
index 0000000..c3e5574
--- /dev/null
+++ b/content/webview/PermissionRequest/Application/src/main/res/values/strings.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<resources>
+    <string name="confirmation">This web page wants to use following resources:\n\n%s</string>
+    <string name="allow">Allow</string>
+    <string name="deny">Deny</string>
+</resources>
diff --git a/content/webview/PermissionRequest/Application/tests/src/com/example/android/permissionrequest/test/SampleTests.java b/content/webview/PermissionRequest/Application/tests/src/com/example/android/permissionrequest/test/SampleTests.java
new file mode 100644
index 0000000..a88589b
--- /dev/null
+++ b/content/webview/PermissionRequest/Application/tests/src/com/example/android/permissionrequest/test/SampleTests.java
@@ -0,0 +1,196 @@
+/*
+* Copyright (C) 2014 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package com.example.android.permissionrequest.test;
+
+import android.graphics.Rect;
+import android.os.SystemClock;
+import android.test.ActivityInstrumentationTestCase2;
+import android.view.MotionEvent;
+import android.view.View;
+import android.webkit.ConsoleMessage;
+import android.webkit.WebView;
+
+import com.example.android.permissionrequest.ConfirmationDialogFragment;
+import com.example.android.permissionrequest.MainActivity;
+import com.example.android.permissionrequest.PermissionRequestFragment;
+import com.example.android.permissionrequest.R;
+
+import java.util.concurrent.ConcurrentLinkedQueue;
+
+/**
+ * Tests for PermissionRequest sample.
+ */
+public class SampleTests extends ActivityInstrumentationTestCase2<MainActivity> {
+
+    private MainActivity mTestActivity;
+    private PermissionRequestFragment mTestFragment;
+
+    public SampleTests() {
+        super(MainActivity.class);
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        mTestActivity = getActivity();
+        mTestFragment = (PermissionRequestFragment)
+                mTestActivity.getSupportFragmentManager().getFragments().get(1);
+    }
+
+    /**
+     * Test if the test fixture has been set up correctly.
+     */
+    public void testPreconditions() {
+        assertNotNull("mTestActivity is null", mTestActivity);
+        assertNotNull("mTestFragment is null", mTestFragment);
+    }
+
+    public void testWebView_grantPermissionRequest() throws Throwable {
+        View view = mTestFragment.getView();
+        assertNotNull(view);
+        final WebView webView = (WebView) view.findViewById(R.id.web_view);
+        assertNotNull(webView);
+
+        final ConsoleMonitor monitor = new ConsoleMonitor();
+        mTestFragment.setConsoleMonitor(monitor);
+
+        // Click the "Start" button
+        assertTrue(monitor.waitForKeyword("Page loaded", 2000));
+        clickToggle(webView);
+
+        // Wait for the dialog
+        ConfirmationDialogFragment dialogFragment = waitForDialog();
+        assertNotNull(dialogFragment);
+
+        // Click "Allow"
+        monitor.reset();
+        clickDialogButton(dialogFragment, android.R.id.button1);
+
+        assertTrue(monitor.waitForKeyword("Started", 2000));
+
+        // Click the "Stop" button
+        monitor.reset();
+        clickToggle(webView);
+        assertTrue(monitor.waitForKeyword("Stopped", 2000));
+
+        // Click the "Start" button
+        monitor.reset();
+        clickToggle(webView);
+
+        // Wait for the dialog
+        dialogFragment = waitForDialog();
+        assertNotNull(dialogFragment);
+
+        // Click "Deny"
+        monitor.reset();
+        clickDialogButton(dialogFragment, android.R.id.button2);
+        assertTrue(monitor.waitForKeyword("Denied", 2000));
+    }
+
+    /**
+     * Click the Start/Stop button.
+     *
+     * @param webView The {@link WebView}.
+     * @throws Throwable
+     */
+    private void clickToggle(final WebView webView) throws Throwable {
+        runTestOnUiThread(new Runnable() {
+            @Override
+            public void run() {
+                Rect rect = new Rect();
+                webView.getHitRect(rect);
+                int x = rect.width() / 2;
+                int y = 100;
+                MotionEvent event = MotionEvent.obtain(SystemClock.uptimeMillis(),
+                        SystemClock.uptimeMillis() + 100, MotionEvent.ACTION_DOWN, x, y, 0);
+                webView.dispatchTouchEvent(event);
+                event = MotionEvent.obtain(SystemClock.uptimeMillis(),
+                        SystemClock.uptimeMillis() + 100, MotionEvent.ACTION_UP, x, y, 0);
+                webView.dispatchTouchEvent(event);
+            }
+        });
+    }
+
+    /**
+     * Wait for the dialog for 2 seconds (100 ms * 20 trials).
+     *
+     * @return The dialog.
+     * @throws InterruptedException
+     */
+    private ConfirmationDialogFragment waitForDialog() throws InterruptedException {
+        int count = 20;
+        ConfirmationDialogFragment dialog = null;
+        while (0 < count) {
+            dialog = (ConfirmationDialogFragment) mTestFragment.getChildFragmentManager()
+                    .findFragmentByTag("dialog");
+            if (null != dialog) {
+                break;
+            }
+            Thread.sleep(100);
+            --count;
+        }
+        return dialog;
+    }
+
+    /**
+     * Press the specified button on the dialog.
+     *
+     * @param dialogFragment The dialog.
+     * @param buttonId       The resource ID of the button to press.
+     * @throws Throwable
+     */
+    private void clickDialogButton(final ConfirmationDialogFragment dialogFragment,
+                                   final int buttonId) throws Throwable {
+        runTestOnUiThread(new Runnable() {
+            @Override
+            public void run() {
+                dialogFragment.getDialog().findViewById(buttonId).performClick();
+                assertFalse(dialogFragment.isVisible());
+            }
+        });
+    }
+
+    private class ConsoleMonitor implements PermissionRequestFragment.ConsoleMonitor {
+
+        private final ConcurrentLinkedQueue<String> mMessages = new ConcurrentLinkedQueue<String>();
+
+        @Override
+        public void onConsoleMessage(ConsoleMessage message) {
+            mMessages.offer(message.message());
+        }
+
+        public boolean waitForKeyword(String keyword, long timeoutMs) throws InterruptedException {
+            long time = 0;
+            while (time < timeoutMs) {
+                String message;
+                while (null != (message = mMessages.poll())) {
+                    if (message.contains(keyword)) {
+                        return true;
+                    }
+                }
+                Thread.sleep(100);
+                time += 100;
+            }
+            return false;
+        }
+
+        public void reset() {
+            mMessages.clear();
+        }
+
+    }
+
+}
diff --git a/content/webview/PermissionRequest/build.gradle b/content/webview/PermissionRequest/build.gradle
new file mode 100644
index 0000000..18f393f
--- /dev/null
+++ b/content/webview/PermissionRequest/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/content/webview/PermissionRequest/buildSrc/build.gradle b/content/webview/PermissionRequest/buildSrc/build.gradle
new file mode 100644
index 0000000..7cebf71
--- /dev/null
+++ b/content/webview/PermissionRequest/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/content/webview/PermissionRequest/gradle/wrapper/gradle-wrapper.jar b/content/webview/PermissionRequest/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..8c0fb64
--- /dev/null
+++ b/content/webview/PermissionRequest/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/content/webview/PermissionRequest/gradle/wrapper/gradle-wrapper.properties b/content/webview/PermissionRequest/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..4eda7c5
--- /dev/null
+++ b/content/webview/PermissionRequest/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Tue Dec 09 18:05:08 JST 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/content/webview/PermissionRequest/gradlew b/content/webview/PermissionRequest/gradlew
new file mode 100755
index 0000000..91a7e26
--- /dev/null
+++ b/content/webview/PermissionRequest/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/content/webview/PermissionRequest/gradlew.bat b/content/webview/PermissionRequest/gradlew.bat
new file mode 100644
index 0000000..aec9973
--- /dev/null
+++ b/content/webview/PermissionRequest/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/content/webview/PermissionRequest/screenshots/icon_web.png b/content/webview/PermissionRequest/screenshots/icon_web.png
new file mode 100644
index 0000000..4a8c2f1
--- /dev/null
+++ b/content/webview/PermissionRequest/screenshots/icon_web.png
Binary files differ
diff --git a/content/webview/PermissionRequest/screenshots/image1.png b/content/webview/PermissionRequest/screenshots/image1.png
new file mode 100644
index 0000000..9ce9fc8
--- /dev/null
+++ b/content/webview/PermissionRequest/screenshots/image1.png
Binary files differ
diff --git a/content/webview/PermissionRequest/screenshots/image2.png b/content/webview/PermissionRequest/screenshots/image2.png
new file mode 100644
index 0000000..e919bd1
--- /dev/null
+++ b/content/webview/PermissionRequest/screenshots/image2.png
Binary files differ
diff --git a/content/webview/PermissionRequest/settings.gradle b/content/webview/PermissionRequest/settings.gradle
new file mode 100644
index 0000000..9464a35
--- /dev/null
+++ b/content/webview/PermissionRequest/settings.gradle
@@ -0,0 +1 @@
+include 'Application'
diff --git a/content/webview/PermissionRequest/template-params.xml b/content/webview/PermissionRequest/template-params.xml
new file mode 100644
index 0000000..0402270
--- /dev/null
+++ b/content/webview/PermissionRequest/template-params.xml
@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<sample>
+    <name>PermissionRequest</name>
+    <group>Content</group>
+    <package>com.example.android.permissionrequest</package>
+
+    <minSdk>21</minSdk>
+
+    <strings>
+        <intro>
+            <![CDATA[
+            This sample shows how to handle PermissionRequest coming from web apps inside of a
+            WebView.
+            ]]>
+        </intro>
+    </strings>
+
+    <template src="base"/>
+    <template src="FragmentView"/>
+    <common src="logger"/>
+    <common src="activities"/>
+
+    <metadata>
+        <status>PUBLISHED</status>
+        <categories>Content</categories>
+        <technologies>Android</technologies>
+        <languages>Java</languages>
+        <solutions>Mobile</solutions>
+        <level>INTERMEDIATE</level>
+        <icon>screenshots/icon_web.png</icon>
+        <screenshots>
+            <img>screenshots/main.png</img>
+        </screenshots>
+        <api_refs>
+            <android>android.webkit.PermissionRequest</android>
+            <android>android.webkit.WebView</android>
+            <android>android.webkit.WebChromeClient</android>
+        </api_refs>
+
+        <description>
+<![CDATA[
+This sample demonstrates how to use the PermissionRequest API to
+securely provide access to restricted system features (such as a
+camera or microphone) from within a WebView. In this example, a dialog
+is created to allow users to explicitly approve or reject each
+request.
+]]>
+        </description>
+
+        <intro>
+<![CDATA[
+PermissionRequest can be used by setting up a custom WebChromeClient.
+
+```java
+mWebView.setWebChromeClient(mWebChromeClient);
+```
+
+In you WebChromeClient implementation, you need to override
+[onPermissionRequest][1]. This method is called when the web content
+is requesting permission to access some resources, providing an
+opportunity to approve or reject the request. In this implementation,
+we display a dialog to allow the user to approve or reject any
+request. In other applications, you may want to implement a whitelist
+of allowed APIs.  Also, override [onPermissionRequestCanceled][2] for
+handling cancellation of the PermissionRequest by the web content.
+
+When the user confirms or denies the request, you can respond back to
+the web content by [grant][3] or [deny][4] respectively.
+
+```java
+mPermissionRequest.grant(mPermissionRequest.getResources());
+```
+
+This sample provides the web content from the assets folder in the
+app. Since WebView is not allowed to use getUserMedia from a "file://"
+URL, the app uses the SimpleWebServer class to provide the content via
+"http://localhost".
+
+[1]: http://developer.android.com/reference/android/webkit/WebChromeClient.html#onPermissionRequest(android.webkit.PermissionRequest)
+[2]: http://developer.android.com/reference/android/webkit/WebChromeClient.html#onPermissionRequestCanceled(android.webkit.PermissionRequest)
+[3]: http://developer.android.com/reference/android/webkit/PermissionRequest.html#grant(java.lang.String[])
+[4]: http://developer.android.com/reference/android/webkit/PermissionRequest.html#deny()
+]]>
+        </intro>
+    </metadata>
+
+</sample>
diff --git a/system/AppUsageStatistics/Application/.gitignore b/system/AppUsageStatistics/Application/.gitignore
new file mode 100644
index 0000000..6eb878d
--- /dev/null
+++ b/system/AppUsageStatistics/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/system/AppUsageStatistics/Application/proguard-project.txt b/system/AppUsageStatistics/Application/proguard-project.txt
new file mode 100644
index 0000000..0d8f171
--- /dev/null
+++ b/system/AppUsageStatistics/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/system/AppUsageStatistics/Application/src/main/AndroidManifest.xml b/system/AppUsageStatistics/Application/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..2726b4a
--- /dev/null
+++ b/system/AppUsageStatistics/Application/src/main/AndroidManifest.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.example.android.appusagestatistics"
+    android:versionCode="1"
+    android:versionName="1.0">
+
+    <uses-permission android:name="android.permission.PACKAGE_USAGE_STATS"/>
+
+    <application android:allowBackup="true"
+        android:label="@string/app_name"
+        android:icon="@drawable/ic_launcher"
+        android:theme="@style/Theme.AppCompat.Light">
+
+        <activity android:name=".AppUsageStatisticsActivity"
+                  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/system/AppUsageStatistics/Application/src/main/java/com/example/android/appusagestatistics/AppUsageStatisticsActivity.java b/system/AppUsageStatistics/Application/src/main/java/com/example/android/appusagestatistics/AppUsageStatisticsActivity.java
new file mode 100644
index 0000000..4def465
--- /dev/null
+++ b/system/AppUsageStatistics/Application/src/main/java/com/example/android/appusagestatistics/AppUsageStatisticsActivity.java
@@ -0,0 +1,37 @@
+/*
+* Copyright 2014 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package com.example.android.appusagestatistics;
+
+import android.os.Bundle;
+import android.support.v7.app.ActionBarActivity;
+
+/**
+ * Launcher Activity for the App Usage Statistics sample app.
+ */
+public class AppUsageStatisticsActivity extends ActionBarActivity {
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.activity_app_usage_statistics);
+        if (savedInstanceState == null) {
+            getSupportFragmentManager().beginTransaction()
+                    .add(R.id.container, AppUsageStatisticsFragment.newInstance())
+                    .commit();
+        }
+    }
+}
\ No newline at end of file
diff --git a/system/AppUsageStatistics/Application/src/main/java/com/example/android/appusagestatistics/AppUsageStatisticsFragment.java b/system/AppUsageStatistics/Application/src/main/java/com/example/android/appusagestatistics/AppUsageStatisticsFragment.java
new file mode 100644
index 0000000..50a72e7
--- /dev/null
+++ b/system/AppUsageStatistics/Application/src/main/java/com/example/android/appusagestatistics/AppUsageStatisticsFragment.java
@@ -0,0 +1,230 @@
+/*
+* Copyright 2014 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package com.example.android.appusagestatistics;
+
+import android.app.usage.UsageStats;
+import android.app.usage.UsageStatsManager;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.graphics.drawable.Drawable;
+import android.os.Bundle;
+import android.provider.Settings;
+import android.support.v4.app.Fragment;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.Button;
+import android.widget.Spinner;
+import android.widget.SpinnerAdapter;
+import android.widget.Toast;
+
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+/**
+ * Fragment that demonstrates how to use App Usage Statistics API.
+ */
+public class AppUsageStatisticsFragment extends Fragment {
+
+    private static final String TAG = AppUsageStatisticsFragment.class.getSimpleName();
+
+    //VisibleForTesting for variables below
+    UsageStatsManager mUsageStatsManager;
+    UsageListAdapter mUsageListAdapter;
+    RecyclerView mRecyclerView;
+    RecyclerView.LayoutManager mLayoutManager;
+    Button mOpenUsageSettingButton;
+    Spinner mSpinner;
+
+    /**
+     * Use this factory method to create a new instance of
+     * this fragment using the provided parameters.
+     *
+     * @return A new instance of fragment {@link AppUsageStatisticsFragment}.
+     */
+    public static AppUsageStatisticsFragment newInstance() {
+        AppUsageStatisticsFragment fragment = new AppUsageStatisticsFragment();
+        return fragment;
+    }
+
+    public AppUsageStatisticsFragment() {
+        // Required empty public constructor
+    }
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        mUsageStatsManager = (UsageStatsManager) getActivity()
+                .getSystemService("usagestats"); //Context.USAGE_STATS_SERVICE
+    }
+
+    @Override
+    public View onCreateView(LayoutInflater inflater, ViewGroup container,
+            Bundle savedInstanceState) {
+        return inflater.inflate(R.layout.fragment_app_usage_statistics, container, false);
+    }
+
+    @Override
+    public void onViewCreated(View rootView, Bundle savedInstanceState) {
+        super.onViewCreated(rootView, savedInstanceState);
+
+        mLayoutManager = new LinearLayoutManager(getActivity());
+        mUsageListAdapter = new UsageListAdapter();
+        mRecyclerView = (RecyclerView) rootView.findViewById(R.id.recyclerview_app_usage);
+        mRecyclerView.setLayoutManager(mLayoutManager);
+        mRecyclerView.scrollToPosition(0);
+        mRecyclerView.setAdapter(mUsageListAdapter);
+        mOpenUsageSettingButton = (Button) rootView.findViewById(R.id.button_open_usage_setting);
+        mSpinner = (Spinner) rootView.findViewById(R.id.spinner_time_span);
+        SpinnerAdapter spinnerAdapter = ArrayAdapter.createFromResource(getActivity(),
+                R.array.action_list, android.R.layout.simple_spinner_dropdown_item);
+        mSpinner.setAdapter(spinnerAdapter);
+        mSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
+
+            String[] strings = getResources().getStringArray(R.array.action_list);
+
+            @Override
+            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
+                StatsUsageInterval statsUsageInterval = StatsUsageInterval.getValue(strings[position]);
+                if (statsUsageInterval != null ) {
+                    List<UsageStats> usageStatsList =
+                            getUsageStatistics(statsUsageInterval.mInterval);
+                    Collections.sort(usageStatsList, new LastTimeLaunchedComparatorDesc());
+                    updateAppsList(usageStatsList);
+                }
+            }
+
+            @Override
+            public void onNothingSelected(AdapterView<?> parent) {
+            }
+        });
+        getUsageStatistics(UsageStatsManager.INTERVAL_DAILY);
+    }
+
+    /**
+     * Returns the {@link #mRecyclerView} sorted by the timestamp of the last time used
+     * including the time span specified by the intervalType argument.
+     *
+     * @param intervalType The time interval by which the stats are aggregated.
+     *                     Corresponding to the value of {@link UsageStatsManager}.
+     *                     E.g. {@link UsageStatsManager#INTERVAL_DAILY}, {@link
+     *                     UsageStatsManager#INTERVAL_WEEKLY},
+     */
+    public List<UsageStats> getUsageStatistics(int intervalType) {
+        // Get the app statistics since one year ago from the current time.
+        Calendar cal = Calendar.getInstance();
+        cal.add(Calendar.YEAR, -1);
+
+        List<UsageStats> queryUsageStats = mUsageStatsManager
+                .queryUsageStats(intervalType, cal.getTimeInMillis(),
+                        System.currentTimeMillis());
+
+        if (queryUsageStats.size() == 0) {
+            Log.i(TAG, "The user may not allow the access to apps usage. ");
+            Toast.makeText(getActivity(),
+                    getString(R.string.explanation_access_to_appusage_is_not_enabled),
+                    Toast.LENGTH_LONG).show();
+            mOpenUsageSettingButton.setVisibility(View.VISIBLE);
+            mOpenUsageSettingButton.setOnClickListener(new View.OnClickListener() {
+                @Override
+                public void onClick(View v) {
+                    startActivity(new Intent(Settings.ACTION_USAGE_ACCESS_SETTINGS));
+                }
+            });
+        }
+        return queryUsageStats;
+    }
+
+    /**
+     * Updates the {@link #mRecyclerView} with the list of {@link UsageStats} passed as an argument.
+     *
+     * @param usageStatsList A list of {@link UsageStats} from which update the
+     *                       {@link #mRecyclerView}.
+     */
+    void updateAppsList(List<UsageStats> usageStatsList) {
+        List<CustomUsageStats> customUsageStatsList = new ArrayList<>();
+        for (int i = 0; i < usageStatsList.size(); i++) {
+            CustomUsageStats customUsageStats = new CustomUsageStats();
+            customUsageStats.usageStats = usageStatsList.get(i);
+            try {
+                Drawable appIcon = getActivity().getPackageManager()
+                        .getApplicationIcon(customUsageStats.usageStats.getPackageName());
+                customUsageStats.appIcon = appIcon;
+            } catch (PackageManager.NameNotFoundException e) {
+                Log.w(TAG, String.format("App Icon is not found for %s",
+                        customUsageStats.usageStats.getPackageName()));
+                customUsageStats.appIcon = getActivity()
+                        .getDrawable(R.drawable.ic_default_app_launcher);
+            }
+            customUsageStatsList.add(customUsageStats);
+        }
+        mUsageListAdapter.setCustomUsageStatsList(customUsageStatsList);
+        mUsageListAdapter.notifyDataSetChanged();
+        mRecyclerView.scrollToPosition(0);
+    }
+
+    /**
+     * The {@link Comparator} to sort a collection of {@link UsageStats} sorted by the timestamp
+     * last time the app was used in the descendant order.
+     */
+    private static class LastTimeLaunchedComparatorDesc implements Comparator<UsageStats> {
+
+        @Override
+        public int compare(UsageStats left, UsageStats right) {
+            return (int) (right.getLastTimeUsed() - left.getLastTimeUsed());
+        }
+    }
+
+    /**
+     * Enum represents the intervals for {@link android.app.usage.UsageStatsManager} so that
+     * values for intervals can be found by a String representation.
+     *
+     */
+    //VisibleForTesting
+    static enum StatsUsageInterval {
+        DAILY("Daily", UsageStatsManager.INTERVAL_DAILY),
+        WEEKLY("Weekly", UsageStatsManager.INTERVAL_WEEKLY),
+        MONTHLY("Monthly", UsageStatsManager.INTERVAL_MONTHLY),
+        YEARLY("Yearly", UsageStatsManager.INTERVAL_YEARLY);
+
+        private int mInterval;
+        private String mStringRepresentation;
+
+        StatsUsageInterval(String stringRepresentation, int interval) {
+            mStringRepresentation = stringRepresentation;
+            mInterval = interval;
+        }
+
+        static StatsUsageInterval getValue(String stringRepresentation) {
+            for (StatsUsageInterval statsUsageInterval : values()) {
+                if (statsUsageInterval.mStringRepresentation.equals(stringRepresentation)) {
+                    return statsUsageInterval;
+                }
+            }
+            return null;
+        }
+    }
+}
diff --git a/system/AppUsageStatistics/Application/src/main/java/com/example/android/appusagestatistics/CustomUsageStats.java b/system/AppUsageStatistics/Application/src/main/java/com/example/android/appusagestatistics/CustomUsageStats.java
new file mode 100644
index 0000000..b5b15c4
--- /dev/null
+++ b/system/AppUsageStatistics/Application/src/main/java/com/example/android/appusagestatistics/CustomUsageStats.java
@@ -0,0 +1,28 @@
+/*
+* Copyright 2014 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package com.example.android.appusagestatistics;
+
+import android.app.usage.UsageStats;
+import android.graphics.drawable.Drawable;
+
+/**
+ * Entity class represents usage stats and app icon.
+ */
+public class CustomUsageStats {
+    public UsageStats usageStats;
+    public Drawable appIcon;
+}
diff --git a/system/AppUsageStatistics/Application/src/main/java/com/example/android/appusagestatistics/UsageListAdapter.java b/system/AppUsageStatistics/Application/src/main/java/com/example/android/appusagestatistics/UsageListAdapter.java
new file mode 100644
index 0000000..ab1d037
--- /dev/null
+++ b/system/AppUsageStatistics/Application/src/main/java/com/example/android/appusagestatistics/UsageListAdapter.java
@@ -0,0 +1,95 @@
+/*
+* Copyright (C) 2014 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package com.example.android.appusagestatistics;
+
+import android.support.v7.widget.RecyclerView;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Provide views to RecyclerView with the directory entries.
+ */
+public class UsageListAdapter extends RecyclerView.Adapter<UsageListAdapter.ViewHolder> {
+
+    private List<CustomUsageStats> mCustomUsageStatsList = new ArrayList<>();
+    private DateFormat mDateFormat = new SimpleDateFormat();
+
+    /**
+     * Provide a reference to the type of views that you are using (custom ViewHolder)
+     */
+    public static class ViewHolder extends RecyclerView.ViewHolder {
+        private final TextView mPackageName;
+        private final TextView mLastTimeUsed;
+        private final ImageView mAppIcon;
+
+        public ViewHolder(View v) {
+            super(v);
+            mPackageName = (TextView) v.findViewById(R.id.textview_package_name);
+            mLastTimeUsed = (TextView) v.findViewById(R.id.textview_last_time_used);
+            mAppIcon = (ImageView) v.findViewById(R.id.app_icon);
+        }
+
+        public TextView getLastTimeUsed() {
+            return mLastTimeUsed;
+        }
+
+        public TextView getPackageName() {
+            return mPackageName;
+        }
+
+        public ImageView getAppIcon() {
+            return mAppIcon;
+        }
+    }
+
+    public UsageListAdapter() {
+    }
+
+    @Override
+    public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
+        View v = LayoutInflater.from(viewGroup.getContext())
+                .inflate(R.layout.usage_row, viewGroup, false);
+        return new ViewHolder(v);
+    }
+
+    @Override
+    public void onBindViewHolder(ViewHolder viewHolder, final int position) {
+        viewHolder.getPackageName().setText(
+                mCustomUsageStatsList.get(position).usageStats.getPackageName());
+        long lastTimeUsed = mCustomUsageStatsList.get(position).usageStats.getLastTimeUsed();
+        viewHolder.getLastTimeUsed().setText(mDateFormat.format(new Date(lastTimeUsed)));
+        viewHolder.getAppIcon().setImageDrawable(mCustomUsageStatsList.get(position).appIcon);
+    }
+
+    @Override
+    public int getItemCount() {
+        return mCustomUsageStatsList.size();
+    }
+
+    public void setCustomUsageStatsList(List<CustomUsageStats> customUsageStats) {
+        mCustomUsageStatsList = customUsageStats;
+    }
+}
\ No newline at end of file
diff --git a/system/AppUsageStatistics/Application/src/main/res/drawable-hdpi/ic_default_app_launcher.png b/system/AppUsageStatistics/Application/src/main/res/drawable-hdpi/ic_default_app_launcher.png
new file mode 100644
index 0000000..96a442e
--- /dev/null
+++ b/system/AppUsageStatistics/Application/src/main/res/drawable-hdpi/ic_default_app_launcher.png
Binary files differ
diff --git a/system/AppUsageStatistics/Application/src/main/res/drawable-hdpi/ic_launcher.png b/system/AppUsageStatistics/Application/src/main/res/drawable-hdpi/ic_launcher.png
new file mode 100755
index 0000000..3cf5e8b
--- /dev/null
+++ b/system/AppUsageStatistics/Application/src/main/res/drawable-hdpi/ic_launcher.png
Binary files differ
diff --git a/system/AppUsageStatistics/Application/src/main/res/drawable-mdpi/ic_default_app_launcher.png b/system/AppUsageStatistics/Application/src/main/res/drawable-mdpi/ic_default_app_launcher.png
new file mode 100644
index 0000000..359047d
--- /dev/null
+++ b/system/AppUsageStatistics/Application/src/main/res/drawable-mdpi/ic_default_app_launcher.png
Binary files differ
diff --git a/system/AppUsageStatistics/Application/src/main/res/drawable-mdpi/ic_launcher.png b/system/AppUsageStatistics/Application/src/main/res/drawable-mdpi/ic_launcher.png
new file mode 100755
index 0000000..51553c5
--- /dev/null
+++ b/system/AppUsageStatistics/Application/src/main/res/drawable-mdpi/ic_launcher.png
Binary files differ
diff --git a/system/AppUsageStatistics/Application/src/main/res/drawable-xhdpi/ic_default_app_launcher.png b/system/AppUsageStatistics/Application/src/main/res/drawable-xhdpi/ic_default_app_launcher.png
new file mode 100644
index 0000000..71c6d76
--- /dev/null
+++ b/system/AppUsageStatistics/Application/src/main/res/drawable-xhdpi/ic_default_app_launcher.png
Binary files differ
diff --git a/system/AppUsageStatistics/Application/src/main/res/drawable-xhdpi/ic_launcher.png b/system/AppUsageStatistics/Application/src/main/res/drawable-xhdpi/ic_launcher.png
new file mode 100755
index 0000000..5248000
--- /dev/null
+++ b/system/AppUsageStatistics/Application/src/main/res/drawable-xhdpi/ic_launcher.png
Binary files differ
diff --git a/system/AppUsageStatistics/Application/src/main/res/drawable-xxhdpi/ic_default_app_launcher.png b/system/AppUsageStatistics/Application/src/main/res/drawable-xxhdpi/ic_default_app_launcher.png
new file mode 100644
index 0000000..4df1894
--- /dev/null
+++ b/system/AppUsageStatistics/Application/src/main/res/drawable-xxhdpi/ic_default_app_launcher.png
Binary files differ
diff --git a/system/AppUsageStatistics/Application/src/main/res/drawable-xxhdpi/ic_launcher.png b/system/AppUsageStatistics/Application/src/main/res/drawable-xxhdpi/ic_launcher.png
new file mode 100755
index 0000000..7f16200
--- /dev/null
+++ b/system/AppUsageStatistics/Application/src/main/res/drawable-xxhdpi/ic_launcher.png
Binary files differ
diff --git a/system/AppUsageStatistics/Application/src/main/res/layout/activity_app_usage_statistics.xml b/system/AppUsageStatistics/Application/src/main/res/layout/activity_app_usage_statistics.xml
new file mode 100644
index 0000000..2627c8b
--- /dev/null
+++ b/system/AppUsageStatistics/Application/src/main/res/layout/activity_app_usage_statistics.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+             xmlns:tools="http://schemas.android.com/tools"
+             android:id="@+id/container"
+             android:layout_width="match_parent"
+             android:layout_height="match_parent"
+             tools:context="com.example.android.appusagestatistics.AppUsageStatisticsActivity"
+             tools:ignore="MergeRootFrame" />
diff --git a/system/AppUsageStatistics/Application/src/main/res/layout/fragment_app_usage_statistics.xml b/system/AppUsageStatistics/Application/src/main/res/layout/fragment_app_usage_statistics.xml
new file mode 100644
index 0000000..1d567b7
--- /dev/null
+++ b/system/AppUsageStatistics/Application/src/main/res/layout/fragment_app_usage_statistics.xml
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+              android:gravity="center_vertical"
+              android:layout_width="match_parent"
+              android:layout_height="match_parent"
+              android:orientation="vertical"
+              android:padding="@dimen/margin_medium">
+
+    <Button android:id="@+id/button_open_usage_setting"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:text="@string/open_app_usage_setting"
+            android:visibility="gone"
+            />
+
+    <LinearLayout android:layout_width="wrap_content"
+                  android:layout_height="wrap_content"
+                  android:orientation="horizontal"
+            >
+        <TextView android:layout_width="wrap_content"
+                  android:layout_height="wrap_content"
+                  android:text="@string/time_span"
+                />
+
+        <Spinner android:id="@+id/spinner_time_span"
+                 android:layout_width="wrap_content"
+                 android:layout_height="wrap_content"/>
+    </LinearLayout>
+
+    <android.support.v7.widget.RecyclerView
+            android:id="@+id/recyclerview_app_usage"
+            android:layout_marginLeft="@dimen/margin_small"
+            android:layout_marginRight="@dimen/margin_small"
+            android:scrollbars="vertical"
+            android:drawSelectorOnTop="true"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"/>
+
+</LinearLayout>
diff --git a/system/AppUsageStatistics/Application/src/main/res/layout/usage_row.xml b/system/AppUsageStatistics/Application/src/main/res/layout/usage_row.xml
new file mode 100644
index 0000000..c16f039
--- /dev/null
+++ b/system/AppUsageStatistics/Application/src/main/res/layout/usage_row.xml
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                android:layout_width="match_parent"
+                android:layout_height="@dimen/usage_row_height"
+        >
+
+    <LinearLayout android:layout_width="wrap_content"
+                  android:layout_height="wrap_content"
+                  android:orientation="horizontal"
+                  android:layout_centerVertical="true"
+                  android:gravity="center_vertical"
+            >
+        <ImageView android:id="@+id/app_icon"
+                   android:layout_width="wrap_content"
+                   android:layout_height="wrap_content"
+                />
+        <LinearLayout android:layout_width="wrap_content"
+                      android:layout_height="wrap_content"
+                      android:layout_marginLeft="@dimen/margin_medium"
+                      android:orientation="vertical"
+                >
+
+            <TextView
+                    android:id="@+id/textview_package_name"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    style="@style/PackageNameFont"
+                    />
+
+            <LinearLayout android:layout_width="wrap_content"
+                          android:layout_height="wrap_content"
+                          android:orientation="horizontal"
+                    >
+
+                <TextView
+                        android:id="@+id/textview_last_time_used_label"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:text="@string/last_time_used"
+                        />
+
+                <TextView
+                        android:id="@+id/textview_last_time_used"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        />
+            </LinearLayout>
+        </LinearLayout>
+    </LinearLayout>
+
+    <View android:id="@+id/divider"
+          android:layout_width="match_parent"
+          android:layout_height="1dp"
+          android:background="#bbbbbb"/>
+
+</RelativeLayout>
\ No newline at end of file
diff --git a/system/AppUsageStatistics/Application/src/main/res/values/dimens.xml b/system/AppUsageStatistics/Application/src/main/res/values/dimens.xml
new file mode 100644
index 0000000..d1741c3
--- /dev/null
+++ b/system/AppUsageStatistics/Application/src/main/res/values/dimens.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<resources>
+    <dimen name="usage_row_height">72dp</dimen>
+</resources>
\ No newline at end of file
diff --git a/system/AppUsageStatistics/Application/src/main/res/values/navigation_items.xml b/system/AppUsageStatistics/Application/src/main/res/values/navigation_items.xml
new file mode 100644
index 0000000..b36a4a5
--- /dev/null
+++ b/system/AppUsageStatistics/Application/src/main/res/values/navigation_items.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<resources>
+    <string-array name="action_list">
+        <item>Daily</item>
+        <item>Weekly</item>
+        <item>Monthly</item>
+        <item>Yearly</item>
+    </string-array>
+</resources>
\ No newline at end of file
diff --git a/system/AppUsageStatistics/Application/src/main/res/values/strings.xml b/system/AppUsageStatistics/Application/src/main/res/values/strings.xml
new file mode 100644
index 0000000..2caaf90
--- /dev/null
+++ b/system/AppUsageStatistics/Application/src/main/res/values/strings.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<resources>
+    <string name="open_app_usage_setting">Open Apps with usage access settings</string>
+    <string name="last_time_used">"Last time used: "</string>
+    <string name="time_span">"Time span: "</string>
+    <string name="explanation_access_to_appusage_is_not_enabled">Failed to retrieve app usage
+        statistics. You may need to enable access "
+        + "for this app through Settings > Security > Apps with usage access
+    </string>
+</resources>
diff --git a/system/AppUsageStatistics/Application/src/main/res/values/styles.xml b/system/AppUsageStatistics/Application/src/main/res/values/styles.xml
new file mode 100644
index 0000000..d400276
--- /dev/null
+++ b/system/AppUsageStatistics/Application/src/main/res/values/styles.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<resources>
+    <style name="PackageNameFont" parent="@android:style/TextAppearance.Small">
+        <item name="android:textColor">#000000</item>
+    </style>
+</resources>
\ No newline at end of file
diff --git a/system/AppUsageStatistics/Application/tests/src/com/example/android/appusagestatistics/AppUsageStatisticsActivityTests.java b/system/AppUsageStatistics/Application/tests/src/com/example/android/appusagestatistics/AppUsageStatisticsActivityTests.java
new file mode 100644
index 0000000..f2e3ea9
--- /dev/null
+++ b/system/AppUsageStatistics/Application/tests/src/com/example/android/appusagestatistics/AppUsageStatisticsActivityTests.java
@@ -0,0 +1,70 @@
+/*
+* Copyright 2014 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+/*
+* Copyright (C) 2014 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*      http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package com.example.android.appusagestatistics;
+
+import android.test.ActivityInstrumentationTestCase2;
+
+/**
+ * Tests for {@link AppUsageStatisticsActivity}.
+ */
+public class AppUsageStatisticsActivityTests
+        extends ActivityInstrumentationTestCase2<AppUsageStatisticsActivity> {
+
+    private AppUsageStatisticsActivity mTestActivity;
+    private AppUsageStatisticsFragment mTestFragment;
+
+    public AppUsageStatisticsActivityTests() {
+        super(AppUsageStatisticsActivity.class);
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        // Starts the activity under test using the default Intent with:
+        // action = {@link Intent#ACTION_MAIN}
+        // flags = {@link Intent#FLAG_ACTIVITY_NEW_TASK}
+        // All other fields are null or empty.
+        mTestActivity = getActivity();
+        mTestFragment = (AppUsageStatisticsFragment)
+                mTestActivity.getSupportFragmentManager().getFragments().get(0);
+    }
+
+    /**
+     * Test if the test fixture has been set up correctly.
+     */
+    public void testPreconditions() {
+        //Try to add a message to add context to your assertions. These messages will be shown if
+        //a tests fails and make it easy to understand why a test failed
+        assertNotNull("mTestActivity is null", mTestActivity);
+        assertNotNull("mTestFragment is null", mTestFragment);
+    }
+}
diff --git a/system/AppUsageStatistics/Application/tests/src/com/example/android/appusagestatistics/AppUsageStatisticsFragmentTests.java b/system/AppUsageStatistics/Application/tests/src/com/example/android/appusagestatistics/AppUsageStatisticsFragmentTests.java
new file mode 100644
index 0000000..d8adb1c
--- /dev/null
+++ b/system/AppUsageStatistics/Application/tests/src/com/example/android/appusagestatistics/AppUsageStatisticsFragmentTests.java
@@ -0,0 +1,97 @@
+/*
+* Copyright 2014 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+package com.example.android.appusagestatistics;
+
+import com.example.android.appusagestatistics.AppUsageStatisticsFragment.StatsUsageInterval;
+
+import android.app.usage.UsageStats;
+import android.app.usage.UsageStatsManager;
+import android.test.ActivityInstrumentationTestCase2;
+
+import java.util.List;
+
+/**
+ * Tests for {@link com.example.android.appusagestatistics.AppUsageStatisticsFragment}.
+ */
+public class AppUsageStatisticsFragmentTests
+        extends ActivityInstrumentationTestCase2<AppUsageStatisticsActivity> {
+
+    private AppUsageStatisticsActivity mTestActivity;
+    private AppUsageStatisticsFragment mTestFragment;
+
+    public AppUsageStatisticsFragmentTests() {
+        super(AppUsageStatisticsActivity.class);
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        // Starts the activity under test using the default Intent with:
+        // action = {@link Intent#ACTION_MAIN}
+        // flags = {@link Intent#FLAG_ACTIVITY_NEW_TASK}
+        // All other fields are null or empty.
+        mTestActivity = getActivity();
+        mTestFragment = (AppUsageStatisticsFragment)
+                mTestActivity.getSupportFragmentManager().getFragments().get(0);
+    }
+
+    /**
+     * Test if the test fixture has been set up correctly.
+     */
+    public void testPreconditions() {
+        assertNotNull(mTestFragment.mUsageStatsManager);
+        assertNotNull(mTestFragment.mUsageListAdapter);
+        assertNotNull(mTestFragment.mRecyclerView);
+        assertNotNull(mTestFragment.mLayoutManager);
+        assertNotNull(mTestFragment.mOpenUsageSettingButton);
+        assertNotNull(mTestFragment.mSpinner);
+    }
+
+    public void testStatsUsageInterval_getValue() {
+        assertTrue(StatsUsageInterval.DAILY == StatsUsageInterval.getValue("Daily"));
+        assertTrue(StatsUsageInterval.WEEKLY == StatsUsageInterval.getValue("Weekly"));
+        assertTrue(StatsUsageInterval.MONTHLY == StatsUsageInterval.getValue("Monthly"));
+        assertTrue(StatsUsageInterval.YEARLY == StatsUsageInterval.getValue("Yearly"));
+        assertNull(StatsUsageInterval.getValue("NonExistent"));
+    }
+
+    public void testGetUsageStatistics() {
+        List<UsageStats> usageStatsList = mTestFragment
+                .getUsageStatistics(UsageStatsManager.INTERVAL_DAILY);
+
+        // Whether the usageStatsList has any UsageStats depends on if the app is granted
+        // the access to App usage statistics.
+        // Only check non null here.
+        assertNotNull(usageStatsList);
+    }
+
+    public void testUpdateAppsList() {
+        List<UsageStats> usageStatsList = mTestFragment
+                .getUsageStatistics(UsageStatsManager.INTERVAL_DAILY);
+
+        mTestFragment.updateAppsList(usageStatsList);
+        getInstrumentation().waitForIdleSync();
+
+        // The result depends on if the app is granted the access to App usage statistics.
+        if (usageStatsList.size() == 0) {
+            assertTrue(mTestFragment.mUsageListAdapter.getItemCount() == 0);
+        } else {
+            assertTrue(mTestFragment.mUsageListAdapter.getItemCount() > 0);
+        }
+    }
+}
diff --git a/system/AppUsageStatistics/build.gradle b/system/AppUsageStatistics/build.gradle
new file mode 100644
index 0000000..2b8d1ef
--- /dev/null
+++ b/system/AppUsageStatistics/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/system/AppUsageStatistics/buildSrc/build.gradle b/system/AppUsageStatistics/buildSrc/build.gradle
new file mode 100644
index 0000000..8c294c2
--- /dev/null
+++ b/system/AppUsageStatistics/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/system/AppUsageStatistics/gradle/wrapper/gradle-wrapper.jar b/system/AppUsageStatistics/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..8c0fb64
--- /dev/null
+++ b/system/AppUsageStatistics/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/system/AppUsageStatistics/gradle/wrapper/gradle-wrapper.properties b/system/AppUsageStatistics/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..8a27ebf
--- /dev/null
+++ b/system/AppUsageStatistics/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Sun Dec 07 22:52:45 JST 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/system/AppUsageStatistics/gradlew b/system/AppUsageStatistics/gradlew
new file mode 100755
index 0000000..91a7e26
--- /dev/null
+++ b/system/AppUsageStatistics/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/system/AppUsageStatistics/gradlew.bat b/system/AppUsageStatistics/gradlew.bat
new file mode 100644
index 0000000..aec9973
--- /dev/null
+++ b/system/AppUsageStatistics/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/system/AppUsageStatistics/screenshots/screenshot-1.png b/system/AppUsageStatistics/screenshots/screenshot-1.png
new file mode 100644
index 0000000..ab0da86
--- /dev/null
+++ b/system/AppUsageStatistics/screenshots/screenshot-1.png
Binary files differ
diff --git a/system/AppUsageStatistics/screenshots/screenshot-2.png b/system/AppUsageStatistics/screenshots/screenshot-2.png
new file mode 100644
index 0000000..7663ebd
--- /dev/null
+++ b/system/AppUsageStatistics/screenshots/screenshot-2.png
Binary files differ
diff --git a/system/AppUsageStatistics/screenshots/web-icon.png b/system/AppUsageStatistics/screenshots/web-icon.png
new file mode 100755
index 0000000..68af9d0
--- /dev/null
+++ b/system/AppUsageStatistics/screenshots/web-icon.png
Binary files differ
diff --git a/system/AppUsageStatistics/settings.gradle b/system/AppUsageStatistics/settings.gradle
new file mode 100644
index 0000000..9464a35
--- /dev/null
+++ b/system/AppUsageStatistics/settings.gradle
@@ -0,0 +1 @@
+include 'Application'
diff --git a/system/AppUsageStatistics/template-params.xml b/system/AppUsageStatistics/template-params.xml
new file mode 100644
index 0000000..38f5781
--- /dev/null
+++ b/system/AppUsageStatistics/template-params.xml
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 2014 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<sample>
+    <name>AppUsageStatistics</name>
+    <group>System</group>
+    <package>com.example.android.appusagestatistics</package>
+
+    <minSdk>21</minSdk>
+
+    <dependency>com.android.support:recyclerview-v7:+</dependency>
+    <dependency>com.android.support:appcompat-v7:21.+</dependency>
+
+    <strings>
+        <intro>
+            <![CDATA[
+            This sample explains how to use App usage statistics API, which was introduced
+            in Android 5.0.
+            ]]>
+        </intro>
+    </strings>
+
+    <template src="base" />
+
+    <metadata>
+        <status>DRAFT</status>
+        <categories>System</categories>
+        <technologies>Android</technologies>
+        <languages>Java</languages>
+        <solutions>Mobile</solutions>
+        <level>INTERMEDIATE</level>
+        <icon>screenshots/web-icon.png</icon>
+        <screenshots>
+            <img>screenshots/screenshot-1.png</img>
+            <img>screenshots/screenshot-2.png</img>
+        </screenshots>
+        <api_refs>
+            <android>android.app.usage.UsageStats</android>
+            <android>android.app.usage.UsageStatsManager</android>
+        </api_refs>
+
+        <description>
+<![CDATA[
+A basic app showing how to use App usage statistics API to let users collect statistics related
+to usage of the applications.
+]]>
+        </description>
+
+        <intro>
+<![CDATA[
+The [App usage statistics][1] API allows app developers to collect statistics related to usage of
+the applications. This API provides more detailed usage information than the deprecated
+[getRecentTasks()][2] method.
+
+This example illustrates how to use the App usage statistics API by showing the applications sorted
+by the timestamp of the last time each app was used.
+
+To use this API, you must first declare the `android.permission.PACKAGE_USAGE_STATS` permission
+in your manifest. The user must also enable access for this app through
+`Settings > Security > Apps with usage access`.
+
+To collect the statistics of the app usage, you need to first get the instance of
+[UsageStatsManager][3] by the following code:
+
+```java
+mUsageStatsManager = (UsageStatsManager) getActivity()
+       .getSystemService(Context.USAGE_STATS_SERVICE);
+```
+
+Then you can retrieve the statistics of the app usage by the following method:
+
+```java
+Calendar cal = Calendar.getInstance();
+cal.add(Calendar.YEAR, -1);
+List<UsageStats> queryUsageStats = mUsageStatsManager
+        .queryUsageStats(UsageStatsManager.INTERVAL_DAILY, cal.getTimeInMillis(),
+                System.currentTimeMillis());
+```
+
+The first argument of the [queryUsageStats()][4] is used for the time interval by which the
+stats are aggregated. The second and the third arguments are used for specifying the beginning
+and the end of the range of the stats to include in the results.
+
+[1]: https://developer.android.com/reference/android/app/usage/package-summary.html
+[2]: https://developer.android.com/reference/android/app/ActivityManager.html#getRecentTasks(int%2C%20int)
+[3]: https://developer.android.com/reference/android/app/usage/UsageStatsManager.html
+[4]: https://developer.android.com/reference/android/app/usage/UsageStatsManager.html#queryUsageStats(int%2C%20long%2C%20long)
+]]>
+        </intro>
+    </metadata>
+</sample>
diff --git a/ui/actionbarcompat/ActionBarCompat-ListPopupMenu/screenshots/1-main.png b/ui/actionbarcompat/ActionBarCompat-ListPopupMenu/screenshots/1-main.png
new file mode 100644
index 0000000..f69ed96
--- /dev/null
+++ b/ui/actionbarcompat/ActionBarCompat-ListPopupMenu/screenshots/1-main.png
Binary files differ
diff --git a/ui/actionbarcompat/ActionBarCompat-ListPopupMenu/screenshots/2-popup.png b/ui/actionbarcompat/ActionBarCompat-ListPopupMenu/screenshots/2-popup.png
new file mode 100644
index 0000000..b03862d
--- /dev/null
+++ b/ui/actionbarcompat/ActionBarCompat-ListPopupMenu/screenshots/2-popup.png
Binary files differ
diff --git a/ui/actionbarcompat/ActionBarCompat-ListPopupMenu/screenshots/icon-web.png b/ui/actionbarcompat/ActionBarCompat-ListPopupMenu/screenshots/icon-web.png
new file mode 100644
index 0000000..5220b83
--- /dev/null
+++ b/ui/actionbarcompat/ActionBarCompat-ListPopupMenu/screenshots/icon-web.png
Binary files differ
diff --git a/ui/actionbarcompat/ActionBarCompat-ListPopupMenu/template-params.xml b/ui/actionbarcompat/ActionBarCompat-ListPopupMenu/template-params.xml
index 485142f..d1985dd 100644
--- a/ui/actionbarcompat/ActionBarCompat-ListPopupMenu/template-params.xml
+++ b/ui/actionbarcompat/ActionBarCompat-ListPopupMenu/template-params.xml
@@ -35,4 +35,38 @@
 
     <template src="base"/>
 
+    <metadata>
+        <status>PUBLISHED</status>
+        <categories>UI</categories>
+        <technologies>Android</technologies>
+        <languages>Java</languages>
+        <solutions>Mobile</solutions>
+        <level>INTERMEDIATE</level>
+        <icon>screenshots/icon-web.png</icon>
+        <screenshots>
+            <img>screenshots/1-main.png</img>
+            <img>screenshots/2-popup.png</img>
+        </screenshots>
+        <api_refs>
+            <android>android.support.v7.widget.PopupMenu</android>
+        </api_refs>
+
+        <description>
+<![CDATA[
+This sample shows how to display a pop up menu using PopupMenu from the v7 appcompat library.
+]]>
+        </description>
+
+        <intro>
+<![CDATA[
+This sample displays a list of items and for each item, an icon can be clicked. When it is clicked, a pop up menu is shown, placed below the item, using the [PopupMenu][1] from the v7 appcompat support library.
+
+The sample uses [ListFragment][2] from the v4 support library to display the list. It shows how to instantiate and display the [PopupMenu][1], as well as how to use `setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener())` to process the user actions on the [PopupMenu][1].
+
+[1]: https://developer.android.com/reference/android/support/v7/widget/PopupMenu.html
+[2]: https://developer.android.com/reference/android/support/v4/app/ListFragment.html
+]]>
+        </intro>
+    </metadata>
+
 </sample>
diff --git a/ui/views/RecyclerView/Application/src/main/java/com/example/android/recyclerview/RecyclerViewFragment.java b/ui/views/RecyclerView/Application/src/main/java/com/example/android/recyclerview/RecyclerViewFragment.java
index 019657f..1c0fded 100644
--- a/ui/views/RecyclerView/Application/src/main/java/com/example/android/recyclerview/RecyclerViewFragment.java
+++ b/ui/views/RecyclerView/Application/src/main/java/com/example/android/recyclerview/RecyclerViewFragment.java
@@ -80,7 +80,7 @@
         if (savedInstanceState != null) {
             // Restore saved layout manager type.
             mCurrentLayoutManagerType = (LayoutManagerType) savedInstanceState
-                    .getSerializable(LAYOUT_MANAGER_KEY);
+                    .getSerializable(KEY_LAYOUT_MANAGER);
         }
         setRecyclerViewLayoutManager(mCurrentLayoutManagerType);
 
@@ -143,7 +143,7 @@
     @Override
     public void onSaveInstanceState(Bundle savedInstanceState) {
         // Save currently selected layout manager.
-        savedInstanceState.putSerializable(LAYOUT_MANAGER_KEY, mCurrentLayoutManagerType);
+        savedInstanceState.putSerializable(KEY_LAYOUT_MANAGER, mCurrentLayoutManagerType);
         super.onSaveInstanceState(savedInstanceState);
     }
 
diff --git a/wearable/wear/JumpingJack/screenshots/web-icon.png b/wearable/wear/JumpingJack/screenshots/web-icon.png
new file mode 100644
index 0000000..da3c00a
--- /dev/null
+++ b/wearable/wear/JumpingJack/screenshots/web-icon.png
Binary files differ
diff --git a/wearable/wear/JumpingJack/template-params.xml b/wearable/wear/JumpingJack/template-params.xml
index 7351c1d..7085d5c 100644
--- a/wearable/wear/JumpingJack/template-params.xml
+++ b/wearable/wear/JumpingJack/template-params.xml
@@ -41,4 +41,64 @@
     <common src="logger"/>
     <common src="activities"/>
 
+    <metadata>
+        <status>PUBLISHED</status>
+        <categories>Wearable</categories>
+        <technologies>Android</technologies>
+        <languages>Java</languages>
+        <solutions>Mobile</solutions>
+        <level>INTERMEDIATE</level>
+        <icon>screenshots/web-icon.png</icon>
+        <screenshots>
+            <img>screenshots/jumping_jack.gif</img>
+        </screenshots>
+        <api_refs>
+            <android>android.hardware.SensorEvent</android>
+            <android>android.hardware.SensorEventManager</android>
+        </api_refs>
+
+        <description>
+<![CDATA[
+A basic sample showing how to use the Gravity sensor on the wearable device
+by counting how many jumping jacks you have performed.
+]]>
+        </description>
+
+        <intro>
+<![CDATA[
+[SensorEventListener][1] offers you methods used for receiving notifications from the
+[SensorManager][2] when sensor values have changed.
+
+This example counts how many times Jumping Jakcs are performed by detecting the value
+of the Gravity sensor by the following code:
+
+```java
+@Override
+public void onSensorChanged(SensorEvent event) {
+    detectJump(event.values[0], event.timestamp);
+}
+
+private void detectJump(float xValue, long timestamp) {
+    if ((Math.abs(xValue) > GRAVITY_THRESHOLD)) {
+        if(timestamp - mLastTime < TIME_THRESHOLD_NS && mUp != (xValue > 0)) {
+            onJumpDetected(!mUp);
+        }
+        mUp = xValue > 0;
+        mLastTime = timestamp;
+    }
+}
+```
+
+The detectJump method above assumes that when a person is wearing the watch, the x-component of gravity
+as measured by the Gravity Sensor is +9.8 when the hand is downward and -9.8 when the hand
+is upward (signs are reversed if the watch is worn on the right hand). Since the upward or
+downward may not be completely accurate, we leave some room and instead of 9.8, we use
+GRAVITY_THRESHOLD (7.0f). We also consider the up <-> down movement successful if it takes less than
+TIME_THRESHOLD_NS (2000000000 nanoseconds).
+
+[1]: http://developer.android.com/reference/android/hardware/SensorEventListener.html
+[2]: http://developer.android.com/reference/android/hardware/SensorManager.html
+]]>
+        </intro>
+    </metadata>
 </sample>
diff --git a/wearable/wear/SynchronizedNotifications/screenshots/web-icon.png b/wearable/wear/SynchronizedNotifications/screenshots/web-icon.png
new file mode 100755
index 0000000..2f5f709
--- /dev/null
+++ b/wearable/wear/SynchronizedNotifications/screenshots/web-icon.png
Binary files differ
diff --git a/wearable/wear/SynchronizedNotifications/template-params.xml b/wearable/wear/SynchronizedNotifications/template-params.xml
index 1da36eb..972ab82 100644
--- a/wearable/wear/SynchronizedNotifications/template-params.xml
+++ b/wearable/wear/SynchronizedNotifications/template-params.xml
@@ -42,4 +42,76 @@
     <template src="WearPlusShared"/>
     <common src="logger"/>
     <common src="activities"/>
+
+    <metadata>
+        <status>PUBLISHED</status>
+        <categories>Wearable</categories>
+        <technologies>Android</technologies>
+        <languages>Java</languages>
+        <solutions>Mobile</solutions>
+        <level>INTERMEDIATE</level>
+        <icon>screenshots/web-icon.png</icon>
+        <screenshots>
+            <img>screenshots/different_notifications_phone.png</img>
+            <img>screenshots/different_notifications_wearable.png</img>
+            <img>screenshots/notification_options.png</img>
+            <img>screenshots/watch_only_notification.png</img>
+        </screenshots>
+        <api_refs>
+            <android>com.google.android.gms.wearable.DataApi</android>
+            <android>com.google.android.gms.wearable.Wearable</android>
+            <android>com.google.android.gms.wearable.WearableListenerService</android>
+        </api_refs>
+
+        <description>
+<![CDATA[
+A basic sample showing how to use simple or synchronized notifications.
+This allows users to dismiss events from either their phone or wearable device simultaneously.
+]]>
+        </description>
+
+        <intro>
+<![CDATA[
+The [DataAPI][1] exposes an API for components to read or write data items and assets between
+the handhelds and wearables. A [DataItem][2] is synchronized across all devices in an Android Wear network.
+It is possible to set data items while not connected to any nodes. Those data items will be synchronized
+when the nodes eventually come online.
+
+This example presents three buttons that would trigger three different combinations of
+notifications on the handset and the watch:
+
+1. The first button builds a simple local-only notification on the handset.
+2. The second one creates a wearable-only notification by putting a data item in the shared data
+store and having a [com.google.android.gms.wearable.WearableListenerService][3] listen for
+that on the wearable.
+3. The third one creates a local notification and a wearable notification by combining the above
+two. It, however, demonstrates how one can set things up so that the dismissal of one
+notification results in the dismissal of the other one.
+
+In the #2 and #3 items, the following code is used to synchronize the data between the handheld
+and the wearable devices using DataAPI.
+
+```java
+PutDataMapRequest putDataMapRequest = PutDataMapRequest.create(path);
+putDataMapRequest.getDataMap().putString(Constants.KEY_CONTENT, content);
+putDataMapRequest.getDataMap().putString(Constants.KEY_TITLE, title);
+PutDataRequest request = putDataMapRequest.asPutDataRequest();
+Wearable.DataApi.putDataItem(mGoogleApiClient, request)
+        .setResultCallback(new ResultCallback<DataApi.DataItemResult>() {
+            @Override
+            public void onResult(DataApi.DataItemResult dataItemResult) {
+                if (!dataItemResult.getStatus().isSuccess()) {
+                    Log.e(TAG, "buildWatchOnlyNotification(): Failed to set the data, "
+                            + "status: " + dataItemResult.getStatus().getStatusCode());
+                }
+            }
+        });
+```
+
+[1]: http://developer.android.com/reference/com/google/android/gms/wearable/DataApi.html#putDataItem(com.google.android.gms.common.api.GoogleApiClient%2C%20com.google.android.gms.wearable.PutDataRequest)
+[2]: http://developer.android.com/reference/com/google/android/gms/wearable/DataItem.html
+[3]: https://developer.android.com/reference/com/google/android/gms/wearable/WearableListenerService.html
+]]>
+        </intro>
+    </metadata>
 </sample>