fix NPE on Kindle Fire, which has no SMS DB. Duh.

This commit is contained in:
Eric House 2012-11-07 19:43:08 -08:00
parent 83754d626e
commit 949b804f35

View file

@ -634,24 +634,26 @@ public class SMSService extends Service {
ContentResolver resolver = getContentResolver(); ContentResolver resolver = getContentResolver();
String[] columns = new String[] { "body","address" }; String[] columns = new String[] { "body","address" };
Cursor cursor = resolver.query( uri, columns, null, null, null ); Cursor cursor = resolver.query( uri, columns, null, null, null );
if ( 0 < cursor.getCount() ) { if ( null != cursor ) {
try { if ( 0 < cursor.getCount() ) {
int bodyIndex = cursor.getColumnIndexOrThrow( "body" ); try {
int phoneIndex = cursor.getColumnIndexOrThrow( "address" ); int bodyIndex = cursor.getColumnIndexOrThrow( "body" );
while ( cursor.moveToNext() ) { int phoneIndex = cursor.getColumnIndexOrThrow( "address" );
String msg = fromPublicFmt( cursor.getString( bodyIndex ) ); while ( cursor.moveToNext() ) {
if ( null != msg ) { String msg = fromPublicFmt( cursor.getString( bodyIndex ) );
String number = cursor.getString( phoneIndex ); if ( null != msg ) {
if ( null != number ) { String number = cursor.getString( phoneIndex );
handleFrom( this, msg, number ); if ( null != number ) {
handleFrom( this, msg, number );
}
} }
} }
} catch ( Exception ee ) {
DbgUtils.loge( ee );
} }
} catch ( Exception ee ) {
DbgUtils.loge( ee );
} }
cursor.close();
} }
cursor.close();
} }
private void sendResult( MultiEvent event, Object ... args ) private void sendResult( MultiEvent event, Object ... args )