Improve exception handling logic a bit
This commit is contained in:
parent
87023ebdb3
commit
7e8281e8d4
|
@ -479,15 +479,12 @@ public class DeviceCommunicationService extends Service {
|
||||||
Cursor contactLookup = null;
|
Cursor contactLookup = null;
|
||||||
try {
|
try {
|
||||||
contactLookup = contentResolver.query(uri, null, null, null, null);
|
contactLookup = contentResolver.query(uri, null, null, null, null);
|
||||||
} catch (SecurityException e) {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (contactLookup != null && contactLookup.getCount() > 0) {
|
if (contactLookup != null && contactLookup.getCount() > 0) {
|
||||||
contactLookup.moveToNext();
|
contactLookup.moveToNext();
|
||||||
name = contactLookup.getString(contactLookup.getColumnIndex(ContactsContract.Data.DISPLAY_NAME));
|
name = contactLookup.getString(contactLookup.getColumnIndex(ContactsContract.Data.DISPLAY_NAME));
|
||||||
}
|
}
|
||||||
|
} catch (SecurityException e) {
|
||||||
|
// ignore, just return name below
|
||||||
} finally {
|
} finally {
|
||||||
if (contactLookup != null) {
|
if (contactLookup != null) {
|
||||||
contactLookup.close();
|
contactLookup.close();
|
||||||
|
|
Loading…
Reference in New Issue