From 2a7d41465347ceb19ef54fb2fccd11160523e6cd Mon Sep 17 00:00:00 2001 From: Simon MacDonald Date: Mon, 29 Feb 2016 12:55:28 -0500 Subject: [PATCH] Issue #610: Android: notification does not dismiss after selection button (1.6.x dev) --- src/android/com/adobe/phonegap/push/GCMIntentService.java | 6 ++++-- .../com/adobe/phonegap/push/PushHandlerActivity.java | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/android/com/adobe/phonegap/push/GCMIntentService.java b/src/android/com/adobe/phonegap/push/GCMIntentService.java index d6c1ed37c..4c0c95831 100644 --- a/src/android/com/adobe/phonegap/push/GCMIntentService.java +++ b/src/android/com/adobe/phonegap/push/GCMIntentService.java @@ -322,12 +322,12 @@ public void createNotification(Context context, Bundle extras) { /* * Notification add actions */ - createActions(extras, mBuilder, resources, packageName); + createActions(extras, mBuilder, resources, packageName, notId); mNotificationManager.notify(appName, notId, mBuilder.build()); } - private void createActions(Bundle extras, NotificationCompat.Builder mBuilder, Resources resources, String packageName) { + private void createActions(Bundle extras, NotificationCompat.Builder mBuilder, Resources resources, String packageName, int notId) { Log.d(LOG_TAG, "create actions"); String actions = extras.getString(ACTIONS); if (actions != null) { @@ -345,12 +345,14 @@ private void createActions(Bundle extras, NotificationCompat.Builder mBuilder, R intent.putExtra(CALLBACK, action.getString(CALLBACK)); intent.putExtra(PUSH_BUNDLE, extras); intent.putExtra(FOREGROUND, foreground); + intent.putExtra(NOT_ID, notId); pIntent = PendingIntent.getActivity(this, i, intent, PendingIntent.FLAG_UPDATE_CURRENT); } else { intent = new Intent(this, BackgroundActionButtonHandler.class); intent.putExtra(CALLBACK, action.getString(CALLBACK)); intent.putExtra(PUSH_BUNDLE, extras); intent.putExtra(FOREGROUND, foreground); + intent.putExtra(NOT_ID, notId); pIntent = PendingIntent.getBroadcast(this, i, intent, PendingIntent.FLAG_UPDATE_CURRENT); } diff --git a/src/android/com/adobe/phonegap/push/PushHandlerActivity.java b/src/android/com/adobe/phonegap/push/PushHandlerActivity.java index 6a490dee9..7993d97aa 100644 --- a/src/android/com/adobe/phonegap/push/PushHandlerActivity.java +++ b/src/android/com/adobe/phonegap/push/PushHandlerActivity.java @@ -20,7 +20,7 @@ public class PushHandlerActivity extends Activity implements PushConstants { @Override public void onCreate(Bundle savedInstanceState) { GCMIntentService gcm = new GCMIntentService(); - int notId = getIntent().getIntExtra(NOT_ID, 0); + int notId = getIntent().getExtras().getInt(NOT_ID, 0); Log.d(LOG_TAG, "not id = " + notId); gcm.setNotification(notId, ""); NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);