在我的收件箱中显示消息

时间:2013-02-13 19:51:15

标签: android database inbox

在android中显示收件箱消息时遇到问题。我在一个活动中使用了两个contentresolver。它会影响我的程序吗?这是我的代码:

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
        }

每当我打开我的收件箱时,虽然我的收件箱中有信息,但是无法显示收件箱信息。它显示开始对话。

0 个答案:

没有答案