From fc9c2627963399f989f81d1ea5140a12d3c941ae Mon Sep 17 00:00:00 2001 From: Eric House Date: Mon, 12 Jan 2015 07:27:24 -0800 Subject: [PATCH] catch exception whose cause I'm not sure of but that make it impossible to launch the app when a game gets into a certain state. Probably need to catch exceptions at a top level of game listing process and offer to discard those in which non-recoverable exceptions occur. Later... --- .../src/org/eehouse/android/xw4/Utils.java | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/Utils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/Utils.java index b3e5a1561..84fb492b1 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/Utils.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/Utils.java @@ -265,21 +265,24 @@ public class Utils { if ( s_phonesHash.containsKey( phone ) ) { name = s_phonesHash.get( phone ); } else { - name = null; - ContentResolver contentResolver = context.getContentResolver(); - Cursor cursor = - contentResolver - .query( Uri.withAppendedPath( PhoneLookup.CONTENT_FILTER_URI, - Uri.encode( phone )), - new String[] { PhoneLookup.DISPLAY_NAME }, - null, null, null ); - if ( cursor.moveToNext() ) { - int indx = cursor.getColumnIndex( PhoneLookup.DISPLAY_NAME ); - name = cursor.getString( indx ); + try { + name = null; + ContentResolver contentResolver = context.getContentResolver(); + Cursor cursor = + contentResolver + .query( Uri.withAppendedPath( PhoneLookup.CONTENT_FILTER_URI, + Uri.encode( phone )), + new String[] { PhoneLookup.DISPLAY_NAME }, + null, null, null ); + if ( cursor.moveToNext() ) { + int indx = cursor.getColumnIndex( PhoneLookup.DISPLAY_NAME ); + name = cursor.getString( indx ); + } + cursor.close(); + s_phonesHash.put( phone, name ); + } catch ( Exception ex ) { + name = "not found"; } - cursor.close(); - - s_phonesHash.put( phone, name ); } } if ( null == name && phoneStandsIn ) {