强制阅读群发短信

时间:2013-10-15 11:28:08

标签: android android-contentresolver

您好我正在开发一个Android短信应用程序,并从内置的消息应用程序中获取短信

    Uri uriSMSURI = Uri.parse("content://mms-sms/conversations?simple=true");
    Cursor cursor = getContentResolver().query(uriSMSURI, new String[] {"*"}, null, null, "date desc");

        while (cursor.moveToNext()) 
        {
            snippet = cursor.getString(cursor.getColumnIndexOrThrow("snippet"));
            Long date = cursor.getLong(cursor.getColumnIndexOrThrow("date"));

            recipient_ids = cursor.getString(cursor.getColumnIndexOrThrow("recipient_ids"));
            recipient_ids.split(" ");


            Cursor c = getContentResolver().query(Uri.parse("content://mms-sms/canonical-addresses"), null, "_id = " + recipient_ids, null, null);
            c.moveToFirst();
            phonenumber= c.getString(c.getColumnIndexOrThrow("address")); 


        }

当有任何群组短信时,我会在myApp中关闭力量,如下所示

 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.Sms}: android.database.sqlite.SQLiteException: near "8": syntax error: , while compiling: SELECT _id, address FROM canonical_addresses WHERE _id = 4 8

如何阅读群组短信并将其与_id进行比较。请帮忙。 谢谢!

1 个答案:

答案 0 :(得分:0)

我认为“4”和“8”之间的空间是问题所在。