From cf1a8625261aae90f1b5d467349defe7d4cf31ab Mon Sep 17 00:00:00 2001 From: Marc Blank Date: Tue, 29 May 2012 08:48:16 -0700 Subject: [PATCH] Fix cursor logic for multiple notifications; close cursor Change-Id: I0b2a46d1a89f9d4704929580324ee25f5c19185e --- email2/src/com/android/email/NotificationController.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/email2/src/com/android/email/NotificationController.java b/email2/src/com/android/email/NotificationController.java index c0073f261..42112fbd7 100644 --- a/email2/src/com/android/email/NotificationController.java +++ b/email2/src/com/android/email/NotificationController.java @@ -499,8 +499,8 @@ public class NotificationController { EmailContent.MAILBOX_NOTIFICATION_URI, mailbox.mAccountKey), EmailContent.NOTIFICATION_PROJECTION, null, null, null); - if (messageCursor != null && messageCursor.getCount() > 0) { - try { + try { + if (messageCursor != null && messageCursor.getCount() > 0) { final int maxNumDigestItems = mContext.getResources().getInteger( R.integer.max_num_notification_digest_items); // The body of the notification is the account name, or the label name. @@ -513,6 +513,7 @@ public class NotificationController { int numDigestItems = 0; // We can assume that the current position of the cursor is on the // newest message + messageCursor.moveToFirst(); do { final long messageId = messageCursor.getLong(EmailContent.ID_PROJECTION_COLUMN); @@ -533,7 +534,9 @@ public class NotificationController { // same string was set in as the subtext, we don't want to show a // duplicate string. builder.setContentText(null); - } finally { + } + } finally { + if (messageCursor != null) { messageCursor.close(); } }