diff --git a/samples/ShortcutDemo/publisher/AndroidManifest.xml b/samples/ShortcutDemo/publisher/AndroidManifest.xml
index b6d1232a3..43fb3f6e6 100644
--- a/samples/ShortcutDemo/publisher/AndroidManifest.xml
+++ b/samples/ShortcutDemo/publisher/AndroidManifest.xml
@@ -39,5 +39,6 @@
+
diff --git a/samples/ShortcutDemo/publisher/res/layout/main.xml b/samples/ShortcutDemo/publisher/res/layout/main.xml
index 2a1a3a282..ff659e4b3 100644
--- a/samples/ShortcutDemo/publisher/res/layout/main.xml
+++ b/samples/ShortcutDemo/publisher/res/layout/main.xml
@@ -41,6 +41,12 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:onClick="onDeleteAllPressed"/>
+
Disabled
+
+
+ Show notification
diff --git a/samples/ShortcutDemo/publisher/src/com/example/android/pm/shortcutdemo/ShortcutPublisher.java b/samples/ShortcutDemo/publisher/src/com/example/android/pm/shortcutdemo/ShortcutPublisher.java
index 9b40602e7..97982f632 100644
--- a/samples/ShortcutDemo/publisher/src/com/example/android/pm/shortcutdemo/ShortcutPublisher.java
+++ b/samples/ShortcutDemo/publisher/src/com/example/android/pm/shortcutdemo/ShortcutPublisher.java
@@ -16,6 +16,12 @@
package com.example.android.pm.shortcutdemo;
import android.app.Activity;
+import android.app.Notification;
+import android.app.Notification.Action;
+import android.app.Notification.Builder;
+import android.app.NotificationManager;
+import android.app.PendingIntent;
+import android.app.RemoteInput;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@@ -262,6 +268,23 @@ public class ShortcutPublisher extends Activity {
refreshList();
}
+ public void onShowNotificationPressed(View v) {
+ final PendingIntent receiverIntent =
+ PendingIntent.getBroadcast(this, 0,
+ new Intent().setComponent(new ComponentName(this, ShortcutReceiver.class)),
+ PendingIntent.FLAG_UPDATE_CURRENT);
+ final RemoteInput ri = new RemoteInput.Builder("result").setLabel("Remote input").build();
+
+ final Notification.Builder nb = new Builder(this)
+ .setContentText("Test")
+ .setContentTitle(getPackageName())
+ .setSmallIcon(R.drawable.icon_large_2)
+ .addAction(new Action.Builder(0, "Remote input", receiverIntent)
+ .addRemoteInput(ri)
+ .build());
+ getSystemService(NotificationManager.class).notify(0, nb.build());
+ }
+
class MyAdapter extends ShortcutAdapter {
public MyAdapter(Context context) {
super(context);
diff --git a/samples/ShortcutDemo/publisher/src/com/example/android/pm/shortcutdemo/ShortcutReceiver.java b/samples/ShortcutDemo/publisher/src/com/example/android/pm/shortcutdemo/ShortcutReceiver.java
new file mode 100644
index 000000000..779244f23
--- /dev/null
+++ b/samples/ShortcutDemo/publisher/src/com/example/android/pm/shortcutdemo/ShortcutReceiver.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2016 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.pm.shortcutdemo;
+
+import android.app.NotificationManager;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.util.Log;
+
+public class ShortcutReceiver extends BroadcastReceiver {
+ private static final String TAG = "ShortcutReceiver";
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ Log.i(TAG, "Received: " + intent);
+ context.getSystemService(NotificationManager.class).cancelAll();
+ }
+}