From 53ae9d7fe77c5c1ab0c5e5bc1778f8bb061e71cc Mon Sep 17 00:00:00 2001 From: cketti Date: Thu, 16 Feb 2012 14:52:56 +0100 Subject: [PATCH] Avoid exception when a screen reader is installed but not active. --- src/com/fsck/k9/view/SingleMessageView.java | 22 ++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/com/fsck/k9/view/SingleMessageView.java b/src/com/fsck/k9/view/SingleMessageView.java index 48206f8ed..92699ee2c 100644 --- a/src/com/fsck/k9/view/SingleMessageView.java +++ b/src/com/fsck/k9/view/SingleMessageView.java @@ -102,15 +102,19 @@ public class SingleMessageView extends LinearLayout { // content://.providers.StatusProvider cursor = cr.query(Uri.parse("content://" + screenReader.serviceInfo.packageName + ".providers.StatusProvider"), null, null, null, null); - if (cursor != null) { - cursor.moveToFirst(); - // These content providers use a special cursor that only has - // one element, - // an integer that is 1 if the screen reader is running. - status = cursor.getInt(0); - cursor.close(); - if (status == 1) { - return true; + try { + if (cursor != null && cursor.moveToFirst()) { + // These content providers use a special cursor that only has + // one element, + // an integer that is 1 if the screen reader is running. + status = cursor.getInt(0); + if (status == 1) { + return true; + } + } + } finally { + if (cursor != null) { + cursor.close(); } } }