Search code examples
androidmms

Fetch Image from MMS - Android


I need to fetch image from MMS that having txt and image.

query.getString(cPart.getColumnIndex("ct"); 

...returns text/plain type.

Don't show image type.


Solution

  • Each MMS message has multiple parts stored in the content://mms/part/ table. Some parts may be text, some may be images and other media types. Once you have the ID of the MMS you want to read, query all parts:

    Cursor query = getContentResolver().query(Uri.parse("content://mms/part", null, "mid = " + mmsID, null, null);
    

    If the MMS contains and image, it will have a part whose content type is an image type.

    if(query.moveToFirst()) {
        do {
            String type = query.getString(query.getColumnIndex("ct"));
            if(type.equals("image/bmp") || type.equals("image/jpeg") || ...) 
                //Read the image
        while(query.moveToNext());
    }
    

    Look here for more information about reading MMSs.