Android 基于不带国家/地区代码的电话号码查询短信会话的问题

Android 基于不带国家/地区代码的电话号码查询短信会话的问题,android,sms,android-contentresolver,Android,Sms,Android Contentresolver,这是我的代码片段: void getAllMessages() { if (mValidPhoneNumberString != "") { final String SMS_URI_INBOX = "content://sms/inbox"; int aInt_Thread = 0; try { Uri aUri = Uri.parse(SMS_URI_INBOX);

这是我的代码片段:

void getAllMessages() {
        if (mValidPhoneNumberString != "") {
            final String SMS_URI_INBOX = "content://sms/inbox";
            int aInt_Thread = 0;
            try {
                Uri aUri = Uri.parse(SMS_URI_INBOX);
                String[] aProjection = new String[] { "address", "person",
                        "body", "date", "type", "thread_id" };
                Cursor aCursor = getContentResolver().query(aUri, aProjection,
                        "address=" + "'" + mValidPhoneNumberString + "'", null,
                        "date desc");
                if (aCursor.moveToFirst()) {
                    int aIndex_thread = aCursor.getColumnIndex("thread_id");
                    aInt_Thread = aCursor.getInt(aIndex_thread);
                }

                if (aCursor != null) {
                    Uri SMS_INBOX = Uri.parse("content://sms");
                    Cursor aCur = getContentResolver().query(
                            SMS_INBOX,
                            new String[] { "_id", "address", "person", "body",
                                    "date", "type", "thread_id" },
                            "thread_id" + " = " + aInt_Thread, null,
                            "date" + " ASC");

                    int index_Body = aCur.getColumnIndex("body");
                    int index_Date = aCur.getColumnIndex("date");
                    int index_Type = aCur.getColumnIndex("type");
                    while (aCur.moveToNext()) {

                        String aMessageBody = aCur.getString(index_Body);
                        int aType = aCur.getInt(index_Type);
                        String aMessageNumber = "";
                        try {
                            aMessageNumber = aCur.getString(
                                    aCur.getColumnIndexOrThrow("address"))
                                    .toString();
                        } catch (Exception e) {
                            e.printStackTrace();
                        }

                        long aMessageTimeStamp = aCur.getLong(index_Date);
                        Constants.logInfo("Address", "" + aMessageNumber);
                        Constants.logInfo("BODY", aMessageBody);
                        Constants.logInfo("Type", "" + aType);
                        Constants.logInfo("Date", ""
                                + getFormattedDate(aMessageTimeStamp));
                    }
                    if (!aCur.isClosed()) {
                        aCur.close();
                        aCur = null;
                    }
                }
                if (!aCursor.isClosed()) {
                    aCursor.close();
                    aCursor = null;
                }

            } catch (SQLiteException ex) {
                Constants.logDebug("SQLiteException", ex.getMessage());
            }
        }

    }
这里的“mValidPhoneNumberString”是不带国家代码的电话号码。 现在,当我调用此方法时,它不会返回任何消息,但当我将国家代码添加到提供的号码时,它会显示与电话号码相关的所有对话。 我真的很想知道是否有其他人之前也遇到过同样的问题,他们是如何解决的