1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-16 14:35:04 -05:00

Avoid exception when a screen reader is installed but not active.

This commit is contained in:
cketti 2012-02-16 14:52:56 +01:00
parent 3ee0889529
commit 53ae9d7fe7

View File

@ -102,15 +102,19 @@ public class SingleMessageView extends LinearLayout {
// content://<nameofpackage>.providers.StatusProvider // content://<nameofpackage>.providers.StatusProvider
cursor = cr.query(Uri.parse("content://" + screenReader.serviceInfo.packageName cursor = cr.query(Uri.parse("content://" + screenReader.serviceInfo.packageName
+ ".providers.StatusProvider"), null, null, null, null); + ".providers.StatusProvider"), null, null, null, null);
if (cursor != null) { try {
cursor.moveToFirst(); if (cursor != null && cursor.moveToFirst()) {
// These content providers use a special cursor that only has // These content providers use a special cursor that only has
// one element, // one element,
// an integer that is 1 if the screen reader is running. // an integer that is 1 if the screen reader is running.
status = cursor.getInt(0); status = cursor.getInt(0);
cursor.close(); if (status == 1) {
if (status == 1) { return true;
return true; }
}
} finally {
if (cursor != null) {
cursor.close();
} }
} }
} }