这里导致异常的错误是什么?我在这里找不到任何问题。任何人都可以看到这个:
private Cursor getAllPhoneNumbersForNamesLike(String str){
Cursor tempContact=null;
tempContact=this.getContentResolver().query(uriContact,null,"display_name like ?",new String[]{tokenLike+"%"},null);
if(tempContact!=null && tempContact.getCount()>0){
try{
tempContact.moveToFirst();
Toast.makeText(this,tempContact.getString(tempContact.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)), Toast.LENGTH_LONG).show();
}catch(Exception e){
Toast.makeText(this, "Inside getAllPhoneNumbersForNamesLike catch: "+e.toString(), Toast.LENGTH_LONG).show();
return null;
}
return this.getContentResolver().query(uriSmsRead,null,inClause,null,null);
}
else
return null;
}
答案 0 :(得分:1)
基于您的stacktrace
05-09 04:15:42.888: D/InputEventConsistencyVerifier(3668): KeyEvent: ACTION_UP but key was not down.
05-09 04:15:42.888: D/InputEventConsistencyVerifier(3668): in android.view.ViewRootImpl@40d81208
05-09 04:15:42.888: D/InputEventConsistencyVerifier(3668): 0: sent at 22940735000000, KeyEvent { action=ACTION_UP, keyCode=KEYCODE_ENTER, scanCode=28, metaState=0, flags=0x8, repeatCount=0, eventTime=22940735, downTime=22940633, deviceId=0, source=0x101 }
05-09 04:15:45.408: E/CursorWindow(3668): Failed to read row 0, column -1 from a CursorWindow which has 3 rows, 29 columns
您需要查看
tempContact.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)
听起来像你的29列,不匹配上面的
返回给定列名称的从零开始的索引,如果列不存在,则返回 -1 。如果您希望该列存在,请使用getColumnIndexOrThrow(String),这将使错误更加清晰。
修改强>
试试这个:
getColumnIndexOrThrow((ContactsContract.CommonDataKinds.Phone.NUMBER))
然后将新的LogCat
粘贴到您的问题中。