检索mms地址编号

时间:2011-04-06 05:19:08

标签: android

在我的应用程序中,我可以通过下面的代码获取所有彩信,但我无法获取mms地址。你们这些/女孩能帮助我吗?

    Cursor cursor = activity.getContentResolver().query(Uri.parse("content://mms"),null,null,null,date DESC);
    count = cursor.getCount();
    if (count > 0) {
        cursor.moveToFirst();
        long messageId = cursor.getLong(0);
        long threadId = cursor.getLong(1);
        long timestamp = cursor.getLong(2);
        String subject = cursor.getString(3);
    }

1 个答案:

答案 0 :(得分:5)

从MMS获取地址。做这样的事

在msgnumber中

传递你的messageID。

String add="";
final String[] projection =  new String[] { "address", "contact_id", "charset", "type" };
final String selection = "type=137"; // "type="+ PduHeaders.FROM,

Uri.Builder builder = Uri.parse("content://mms").buildUpon();
builder.appendPath(String.valueOf(msgnumber)).appendPath("addr");

Cursor cursor = context.getContentResolver().query(
    builder.build(),
    projection,
    selection,
    null, null);

    if (cursor.moveToFirst()) {
      add =  cursor.getString(0);
    }

希望这会有所帮助。