Improve exception handling logic a bit

This commit is contained in:
cpfeiffer 2016-03-08 21:32:35 +01:00
parent 87023ebdb3
commit 7e8281e8d4
1 changed files with 2 additions and 5 deletions

View File

@ -479,15 +479,12 @@ public class DeviceCommunicationService extends Service {
Cursor contactLookup = null;
try {
contactLookup = contentResolver.query(uri, null, null, null, null);
} catch (SecurityException e) {
return name;
}
try {
if (contactLookup != null && contactLookup.getCount() > 0) {
contactLookup.moveToNext();
name = contactLookup.getString(contactLookup.getColumnIndex(ContactsContract.Data.DISPLAY_NAME));
}
} catch (SecurityException e) {
// ignore, just return name below
} finally {
if (contactLookup != null) {
contactLookup.close();