Add "BasicNotifications" sample.
A very basic sample showing (a) how to use notifications, and (b)
my proposal for what very basic samples with no UI should look like.
Change-Id: I158e193853e2b5ed785c317b8801170f5774880e
diff --git a/ui/notifications/BasicNotifications/AndroidManifest.xml b/ui/notifications/BasicNotifications/AndroidManifest.xml
new file mode 100644
index 0000000..5193ae6
--- /dev/null
+++ b/ui/notifications/BasicNotifications/AndroidManifest.xml
@@ -0,0 +1,41 @@
+<?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.basicnotifications"
+ android:versionCode="1"
+ android:versionName="1.0">
+
+ <uses-sdk
+ android:minSdkVersion="8"
+ android:targetSdkVersion="17"/>
+
+ <application
+ android:allowBackup="true"
+ android:icon="@drawable/ic_launcher"
+ android:label="@string/app_name"
+ android:theme="@style/AppTheme">
+ <activity
+ android:name=".MainActivity"
+ android:label="@string/app_name">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN"/>
+ <category android:name="android.intent.category.LAUNCHER"/>
+ </intent-filter>
+ </activity>
+ </application>
+
+</manifest>
diff --git a/ui/notifications/BasicNotifications/big_icon.png b/ui/notifications/BasicNotifications/big_icon.png
new file mode 100644
index 0000000..38a25ae
--- /dev/null
+++ b/ui/notifications/BasicNotifications/big_icon.png
Binary files differ
diff --git a/ui/notifications/BasicNotifications/res/drawable-hdpi-v11/ic_stat_notification.png b/ui/notifications/BasicNotifications/res/drawable-hdpi-v11/ic_stat_notification.png
new file mode 100644
index 0000000..604d3a3
--- /dev/null
+++ b/ui/notifications/BasicNotifications/res/drawable-hdpi-v11/ic_stat_notification.png
Binary files differ
diff --git a/ui/notifications/BasicNotifications/res/drawable-hdpi-v9/ic_stat_notification.png b/ui/notifications/BasicNotifications/res/drawable-hdpi-v9/ic_stat_notification.png
new file mode 100644
index 0000000..5c86ffd
--- /dev/null
+++ b/ui/notifications/BasicNotifications/res/drawable-hdpi-v9/ic_stat_notification.png
Binary files differ
diff --git a/ui/notifications/BasicNotifications/res/drawable-hdpi/ic_launcher.png b/ui/notifications/BasicNotifications/res/drawable-hdpi/ic_launcher.png
new file mode 100644
index 0000000..743382b
--- /dev/null
+++ b/ui/notifications/BasicNotifications/res/drawable-hdpi/ic_launcher.png
Binary files differ
diff --git a/ui/notifications/BasicNotifications/res/drawable-hdpi/ic_stat_notification.png b/ui/notifications/BasicNotifications/res/drawable-hdpi/ic_stat_notification.png
new file mode 100644
index 0000000..f39c3b3
--- /dev/null
+++ b/ui/notifications/BasicNotifications/res/drawable-hdpi/ic_stat_notification.png
Binary files differ
diff --git a/ui/notifications/BasicNotifications/res/drawable-ldpi-v11/ic_stat_notification.png b/ui/notifications/BasicNotifications/res/drawable-ldpi-v11/ic_stat_notification.png
new file mode 100644
index 0000000..b919a32
--- /dev/null
+++ b/ui/notifications/BasicNotifications/res/drawable-ldpi-v11/ic_stat_notification.png
Binary files differ
diff --git a/ui/notifications/BasicNotifications/res/drawable-ldpi-v9/ic_stat_notification.png b/ui/notifications/BasicNotifications/res/drawable-ldpi-v9/ic_stat_notification.png
new file mode 100644
index 0000000..1ce3e7e
--- /dev/null
+++ b/ui/notifications/BasicNotifications/res/drawable-ldpi-v9/ic_stat_notification.png
Binary files differ
diff --git a/ui/notifications/BasicNotifications/res/drawable-mdpi-v11/ic_stat_notification.png b/ui/notifications/BasicNotifications/res/drawable-mdpi-v11/ic_stat_notification.png
new file mode 100644
index 0000000..3f4d4a6
--- /dev/null
+++ b/ui/notifications/BasicNotifications/res/drawable-mdpi-v11/ic_stat_notification.png
Binary files differ
diff --git a/ui/notifications/BasicNotifications/res/drawable-mdpi-v9/ic_stat_notification.png b/ui/notifications/BasicNotifications/res/drawable-mdpi-v9/ic_stat_notification.png
new file mode 100644
index 0000000..1dbd17c
--- /dev/null
+++ b/ui/notifications/BasicNotifications/res/drawable-mdpi-v9/ic_stat_notification.png
Binary files differ
diff --git a/ui/notifications/BasicNotifications/res/drawable-mdpi/ic_launcher.png b/ui/notifications/BasicNotifications/res/drawable-mdpi/ic_launcher.png
new file mode 100644
index 0000000..46a51a4
--- /dev/null
+++ b/ui/notifications/BasicNotifications/res/drawable-mdpi/ic_launcher.png
Binary files differ
diff --git a/ui/notifications/BasicNotifications/res/drawable-mdpi/ic_stat_notification.png b/ui/notifications/BasicNotifications/res/drawable-mdpi/ic_stat_notification.png
new file mode 100644
index 0000000..eafbbd1
--- /dev/null
+++ b/ui/notifications/BasicNotifications/res/drawable-mdpi/ic_stat_notification.png
Binary files differ
diff --git a/ui/notifications/BasicNotifications/res/drawable-xhdpi-v11/ic_stat_notification.png b/ui/notifications/BasicNotifications/res/drawable-xhdpi-v11/ic_stat_notification.png
new file mode 100644
index 0000000..d2317d7
--- /dev/null
+++ b/ui/notifications/BasicNotifications/res/drawable-xhdpi-v11/ic_stat_notification.png
Binary files differ
diff --git a/ui/notifications/BasicNotifications/res/drawable-xhdpi-v9/ic_stat_notification.png b/ui/notifications/BasicNotifications/res/drawable-xhdpi-v9/ic_stat_notification.png
new file mode 100644
index 0000000..7011de8
--- /dev/null
+++ b/ui/notifications/BasicNotifications/res/drawable-xhdpi-v9/ic_stat_notification.png
Binary files differ
diff --git a/ui/notifications/BasicNotifications/res/drawable-xhdpi/ic_launcher.png b/ui/notifications/BasicNotifications/res/drawable-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..f97cef3
--- /dev/null
+++ b/ui/notifications/BasicNotifications/res/drawable-xhdpi/ic_launcher.png
Binary files differ
diff --git a/ui/notifications/BasicNotifications/res/drawable-xhdpi/ic_stat_notification.png b/ui/notifications/BasicNotifications/res/drawable-xhdpi/ic_stat_notification.png
new file mode 100644
index 0000000..1f0d652
--- /dev/null
+++ b/ui/notifications/BasicNotifications/res/drawable-xhdpi/ic_stat_notification.png
Binary files differ
diff --git a/ui/notifications/BasicNotifications/res/drawable-xxhdpi/ic_launcher.png b/ui/notifications/BasicNotifications/res/drawable-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..17fa130
--- /dev/null
+++ b/ui/notifications/BasicNotifications/res/drawable-xxhdpi/ic_launcher.png
Binary files differ
diff --git a/ui/notifications/BasicNotifications/res/layout/main_layout.xml b/ui/notifications/BasicNotifications/res/layout/main_layout.xml
new file mode 100644
index 0000000..4b0adf6
--- /dev/null
+++ b/ui/notifications/BasicNotifications/res/layout/main_layout.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+Copyright 2013 The Android Open Source Project
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/coreLayout"
+ android:orientation="vertical"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical">
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/description"
+ android:id="@+id/description"
+ android:scrollbars="vertical"
+ android:layout_gravity="fill_vertical"
+ android:layout_weight="1"/>
+
+ <Button
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Do it!"
+ android:id="@+id/button"
+ android:layout_gravity="center"
+ android:onClick="sendNotification"/>
+
+</LinearLayout>
diff --git a/ui/notifications/BasicNotifications/res/values-v11/styles.xml b/ui/notifications/BasicNotifications/res/values-v11/styles.xml
new file mode 100644
index 0000000..a55cffb
--- /dev/null
+++ b/ui/notifications/BasicNotifications/res/values-v11/styles.xml
@@ -0,0 +1,27 @@
+<?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.
+-->
+<resources>
+
+ <!--
+ Base application theme for API 11+. This theme completely replaces
+ AppBaseTheme from res/values/styles.xml on API 11+ devices.
+ -->
+ <style name="AppBaseTheme" parent="android:Theme.Holo.Light">
+ <!-- API 11 theme customizations can go here. -->
+ </style>
+
+</resources>
diff --git a/ui/notifications/BasicNotifications/res/values-v14/styles.xml b/ui/notifications/BasicNotifications/res/values-v14/styles.xml
new file mode 100644
index 0000000..e010230
--- /dev/null
+++ b/ui/notifications/BasicNotifications/res/values-v14/styles.xml
@@ -0,0 +1,28 @@
+<?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.
+-->
+<resources>
+
+ <!--
+ Base application theme for API 14+. This theme completely replaces
+ AppBaseTheme from BOTH res/values/styles.xml and
+ res/values-v11/styles.xml on API 14+ devices.
+ -->
+ <style name="AppBaseTheme" parent="android:Theme.Holo.Light">
+ <!-- API 14 theme customizations can go here. -->
+ </style>
+
+</resources>
diff --git a/ui/notifications/BasicNotifications/res/values/strings.xml b/ui/notifications/BasicNotifications/res/values/strings.xml
new file mode 100644
index 0000000..d9300ef
--- /dev/null
+++ b/ui/notifications/BasicNotifications/res/values/strings.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.
+-->
+<resources>
+
+ <string name="app_name">Basic Notifications</string>
+ <string name="description">
+ Tap the button below to send a notification.\n\nThe notification\'s icon will immediately
+ appear in the notification bar. Drag the notification bar open to see the full
+ notification. Depending on which version of Android you\'re running, the full
+ notification will display an icon and two or three lines of text.
+ \n\nTap the notification to execute the notification\'s \"action,\" which is an intent
+ that we associate with the notification when it\'s created. This sample notification\'s
+ action is to send a browse intent with the url of the Notification docs on
+ developer.android.com.
+ \n\nThis sample uses the NotificationCompat API for maximum compatibility with versions
+ of Android from Froyo (Android 2.2) to the present. Try it on devices or AVDs that are
+ running different versions of Android. You\'ll see that while the presentation varies
+ slightly, the basic functionality is the same. NotificationCompat automatically takes
+ advantage of the expanded notification format in newer versions of Android, and
+ falls back gracefully to a reduced set of functionality on earlier versions.
+ </string>
+
+</resources>
diff --git a/ui/notifications/BasicNotifications/res/values/styles.xml b/ui/notifications/BasicNotifications/res/values/styles.xml
new file mode 100644
index 0000000..916d51a
--- /dev/null
+++ b/ui/notifications/BasicNotifications/res/values/styles.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.
+-->
+<resources>
+
+ <!--
+ Base application theme, dependent on API level. This theme is replaced
+ by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
+ -->
+ <style name="AppBaseTheme" parent="android:Theme.Light">
+ <!--
+ Theme customizations available in newer API levels can go in
+ res/values-vXX/styles.xml, while customizations related to
+ backward-compatibility can go here.
+ -->
+ </style>
+
+ <!-- Application theme. -->
+ <style name="AppTheme" parent="AppBaseTheme">
+ <!-- All customizations that are NOT specific to a particular API-level can go here. -->
+ </style>
+
+
+</resources>
diff --git a/ui/notifications/BasicNotifications/src/com/example/android/basicnotifications/MainActivity.java b/ui/notifications/BasicNotifications/src/com/example/android/basicnotifications/MainActivity.java
new file mode 100644
index 0000000..50ac798
--- /dev/null
+++ b/ui/notifications/BasicNotifications/src/com/example/android/basicnotifications/MainActivity.java
@@ -0,0 +1,101 @@
+package com.example.android.basicnotifications;
+
+import android.app.Activity;
+import android.app.NotificationManager;
+import android.app.PendingIntent;
+import android.content.Intent;
+import android.graphics.BitmapFactory;
+import android.net.Uri;
+import android.os.Bundle;
+import android.support.v4.app.NotificationCompat;
+import android.view.View;
+
+/**
+ * The entry point to the BasicNotification sample.
+ */
+public class MainActivity extends Activity {
+ /**
+ * A numeric value that identifies the notification that we'll be sending.
+ * This value needs to be unique within this app, but it doesn't need to be
+ * unique system-wide.
+ */
+ public static final int NOTIFICATION_ID = 1;
+
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.main_layout);
+
+ }
+
+ /**
+ * Send a sample notification using the NotificationCompat API.
+ */
+ public void sendNotification(View view) {
+
+ // BEGIN_INCLUDE(build_action)
+ /** Create an intent that will be fired when the user clicks the notification.
+ * The intent needs to be packaged into a {@link android.app.PendingIntent} so that the
+ * notification service can fire it on our behalf.
+ */
+ Intent intent = new Intent(Intent.ACTION_VIEW,
+ Uri.parse("http://developer.android.com/reference/android/app/Notification.html"));
+ PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);
+ // END_INCLUDE(build_action)
+
+ // BEGIN_INCLUDE (build_notification)
+ /**
+ * Use NotificationCompat.Builder to set up our notification.
+ */
+ NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
+
+ /** Set the icon that will appear in the notification bar. This icon also appears
+ * in the lower right hand corner of the notification itself.
+ *
+ * Important note: although you can use any drawable as the small icon, Android
+ * design guidelines state that the icon should be simple and monochrome. Full-color
+ * bitmaps or busy images don't render well on smaller screens and can end up
+ * confusing the user.
+ */
+ builder.setSmallIcon(R.drawable.ic_stat_notification);
+
+ // Set the intent that will fire when the user taps the notification.
+ builder.setContentIntent(pendingIntent);
+
+ // Set the notification to auto-cancel. This means that the notification will disappear
+ // after the user taps it, rather than remaining until it's explicitly dismissed.
+ builder.setAutoCancel(true);
+
+ /**
+ *Build the notification's appearance.
+ * Set the large icon, which appears on the left of the notification. In this
+ * sample we'll set the large icon to be the same as our app icon. The app icon is a
+ * reasonable default if you don't have anything more compelling to use as an icon.
+ */
+ builder.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher));
+
+ /**
+ * Set the text of the notification. This sample sets the three most commononly used
+ * text areas:
+ * 1. The content title, which appears in large type at the top of the notification
+ * 2. The content text, which appears in smaller text below the title
+ * 3. The subtext, which appears under the text on newer devices. Devices running
+ * versions of Android prior to 4.2 will ignore this field, so don't use it for
+ * anything vital!
+ */
+ builder.setContentTitle("BasicNotifications Sample");
+ builder.setContentText("Time to learn about notifications!");
+ builder.setSubText("Tap to view documentation about notifications.");
+
+ // END_INCLUDE (build_notification)
+
+ // BEGIN_INCLUDE(send_notification)
+ /**
+ * Send the notification. This will immediately display the notification icon in the
+ * notification bar.
+ */
+ NotificationManager notificationManager = (NotificationManager) getSystemService(
+ NOTIFICATION_SERVICE);
+ notificationManager.notify(NOTIFICATION_ID, builder.build());
+ // END_INCLUDE(send_notification)
+ }
+}