在 android 中检索呼叫日志时,当我尝试根据索引 1 的投影在“\n”上拆分结果时,索引超出范围
/*
* projection string that will contain the values retrieved
*/
String[] projection = new String[] { Calls.DATE, Calls.NUMBER, Calls.DURATION };
/*
* Cursor to loop on the results of the query
*/
Cursor callLogCursor = getApplicationContext().getContentResolver().query(CallLog.Calls.CONTENT_URI, projection, null, null, CallLog.Calls.DEFAULT_SORT_ORDER);
callLogCursor.moveToFirst();
/*
* Loop through the call log and get the number needed or until
* we retrieved all call logs
*/
String row;
while (callLogCursor.isAfterLast() == false) {
for (int i=0; i<callLogCursor.getColumnCount(); i++) {
row = callLogCursor.getString(i);
String[] parts = row.split("\n");
showToast(callLogCursor.getString(i));
callLogs += CommonUtils.formatDate(parts[0]) + "-" + parts[1] + "-" + parts[2] + "\n";
}
numberOfCallLogRetrieved++;
callLogCursor.moveToNext();
}
不确定我是否在这里遗漏了什么。我真的很感激任何帮助。
吐司连续显示 3 个值
谢谢