1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-12-24 08:38:51 -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
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();
}
}
}