728x90
728x170
Uri uri = Uri.parse("content://mms/");
String selection = "_id = " + mmsId;
Cursor cursor = getContentResolver().query(uri, null, selection, null, null);
 
 
 
String selectionPart = "mid=" + mmsId;
Android.Net.Uri uri = Android.Net.Uri.parse("content://mms/part");
Android.Database.ICursor cursor = ContentResolver.Query(uri, null,
    selectionPart, null, null);
if (cursor.MoveToFirst())
{
    do
    {
        String partId = cursor.GetString(cursor.GetColumnIndex("_id"));
        String type = cursor.GetString(cursor.GetColumnIndex("ct"));
        if ("text/plain".Equals(type))
        {
            String data = cursor.GetString(cursor.GetColumnIndex("_data"));
            String body;
            if (data != null)
            {
                // implementation of this method below
                body = GetMmsText(partId);
            }
            else
            {
                body = cursor.GetString(cursor.GetColumnIndex("text"));
            }
        }
    } while (cursor.MoveToNext());
}

private string getMmsText(String id)
{
    Android.Net.Uri partURI = Android.Net.Uri.Parse("content://mms/part/" + id);
    Stream inputStream = null;
    Java.Lang.StringBuilder sb = new Java.Lang.StringBuilder();
    try
    {
        inputStream = ContentResolver.OpenInputStream(partURI);
        if (inputStream != null)
        {
            Java.IO.InputStreamReader isr = new Java.IO.InputStreamReader(inputStream, "UTF-8");
            Java.IO.BufferedReader reader = new Java.IO.BufferedReader(isr);
            string temp = reader.ReadLine();
            while (temp != null)
            {
                sb.Append(temp);
                temp = reader.ReadLine();
            }
        }
    }
    catch (IOException e) { }
    finally
    {
        if (inputStream != null)
        {
            try
            {
                inputStream.Close();
            }
            catch (IOException e) { }
        }
    }
    return sb.ToString();
}
 

 

728x90
그리드형
Posted by kjun.kr
,