How to get the outgoing mms address in android

I spent 5 days trying different things and googling a lot without luck

I have a broadcast receiver for monitoring and backing up incoming millimeters and SMS. SMS - outgoing and incoming - no problem. MMS however ...

I have a broadcast receiver for incoming MMS, no problem.

However, for outgoing MMS, I use a content observer directed to the content: // mms

is a part that registers a content observer from a class of service

mo = new MMSObserver(new Handler(),getApplicationContext());
        try{
            getContentResolver().unregisterContentObserver(mo);
        }
        finally{
            getContentResolver().registerContentObserver(Uri.parse("content://mms"), true, mo);
        }

This is part of the sharing in the above content watcher

public void onChange(boolean bSelfChange)
{
    super.onChange(bSelfChange);
    Log.i(TAG,"MMSObserver onChange");
    ContentResolver contentResolver = context.getContentResolver();
    Uri uri = Uri.parse("content://mms");
    Cursor cur = contentResolver.quert("content://mms",null,null,null,null)
    if(cur.moveToNext()){
        String id = cur.getString(cur.getColumnIndex("_id"));
        String date = cur.getString (cur.getColumnIndex ("date"));
            String address = getAddress(id);
    }
}
    private static String getAddress(String id){
          String selectionAdd = new String("msg_id=" + id);
            String uriStr = MessageFormat.format("content://mms/{0}/addr", id);
            Uri uriAddress = Uri.parse(uriStr);
            Cursor cAdd = context.getContentResolver().query(uriAddress, null,
                selectionAdd, null, null);
            String name = null;
            if (cAdd.moveToFirst()) {
                do {
                    String number = cAdd.getString(cAdd.getColumnIndex("address"));
                    if (number != null) {
                        try {
                            Long.parseLong(number.replace("-", ""));
                            name = number;
                        } catch (NumberFormatException nfe) {
                            if (name == null) {
                                name = number;
                            }
                        }
                    }
                } while (cAdd.moveToNext());
            }
            if (cAdd != null) {
                cAdd.close();
            }
            return name;
    }

The problem is that the address column always returns "insert-address-token" for outgoing mms. Is there any possible way to get the number that mms is going for?

, , , . , , , , sdk, . sms mms _id . .

MMS- "--"

?

+3
1

- :

Uri uri = Uri.parse("content://mms-sms/conversations/" + mThreadId);
String[] projection = new String[] {
    "body", "person", "sub", "subject", "retr_st", "type", "date", "ct_cls", "sub_cs", "_id", "read", "ct_l", "st", "msg_box", "reply_path_present", "m_cls", "read_status", "ct_t", "status", "retr_txt_cs", "d_rpt", "error_code", "m_id", "date_sent", "m_type", "v", "exp", "pri", "service_center", "address", "rr", "rpt_a", "resp_txt", "locked", "resp_st", "m_size"
};
String sortOrder = "normalized_date";

Cursor mCursor = getActivity().getContentResolver().query(uri, projection, null, null, sortOrder);

String messageAddress;
int type;
while (mCursor.moveToNext()) {
    String messageId = mCursor.getString(mCursor.getColumnIndex("_id"));

    Uri.Builder builder = Uri.parse("content://mms").buildUpon();
    builder.appendPath(messageId).appendPath("addr");
    Cursor c = mContext.getContentResolver().query(builder.build(), new String[] {
        "*"
    }, null, null, null);
    while (c.moveToNext()) {
        messageAddress = c.getString(c.getColumnIndex("address"));

        if (!messageAddress.equals("insert-address-token")) {
            type = c.getInt(c.getColumnIndex("type"));
            c.moveToLast();
        }
    }
    c.close();
}

mCursor moveToNext() , getView() SimpleCursorAdapter.

0

All Articles