在 android 中显示收件箱消息时遇到问题。我在一项活动中使用了两个内容解析器。它会影响我的程序吗?这是我的代码:
ContentResolver contentResolver = getContentResolver();
ContentResolver contentResolverSender = getContentResolver();
Cursor cursorsender = contentResolverSender.query(
Uri.parse("content://sms/sent"), null, "address = "
+ senderAddress, null, null);
Cursor cursor = contentResolver.query(Uri.parse("content://sms/inbox"),
null, "address = " + senderAddress, null, null);
startManagingCursor(cursor);
int indexBody = cursor.getColumnIndex(SmsReceiver.BODY);
int indexAddr = cursor.getColumnIndex(SmsReceiver.ADDRESS);
int dateCol = cursor.getColumnIndex(SmsReceiver.DATE);
int i = 0, flag = 0;
int indexSenderBody = cursorsender.getColumnIndex(SmsReceiver.BODY);
String[] addressUniqueness = null;
String name = null;
if (indexBody < 0 || !cursor.moveToFirst())
return;
int j = 0;
String msgSendStr = null;
if (cursorsender.moveToFirst()) {
for (i = 0; i < cursorsender.getCount(); i++) {
msgSendStr = cursorsender.getString(
cursorsender.getColumnIndexOrThrow("body")).toString();
msgSendStr = makeShortMstToText(msgSendStr);
bodySendMsg[i] = msgSendStr;
long dateInMilliSecSender = cursorsender.getLong(cursorsender
.getColumnIndexOrThrow(SmsReceiver.DATE));
dateSendMsg[i] = dateInMilliSecSender;
cursorsender.moveToNext();
}
}
if (cursor.moveToFirst()) {
do {
String msgStr = cursor.getString(indexBody);
long dateInMilliSec = cursor.getLong(cursor
.getColumnIndexOrThrow(SmsReceiver.DATE));
msgStr = makeShortMstToText(msgStr);
bodyRcvMsg[j] = msgStr;
dateRcvMsg[j] = dateInMilliSec;
j++;
} while (cursor.moveToNext());
// TODO Auto-generated catch block
}
每当我打开收件箱时,虽然我的收件箱中有消息,但无法显示收件箱消息。它显示开始对话。