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つの値を連続して示しています
ありがとう