728x90
728x170
Uri uri = Uri.parse("content://mms/");
String selection = "_id = " + mmsId;
Cursor cursor = getContentResolver().query(uri, null, selection, null, null);
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());
}
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
그리드형
'C# > Xamarin Maui' 카테고리의 다른 글
(Xamarin) 나만의 상단 Tool Bar 만들기 (0) | 2017.04.19 |
---|---|
(Xamarin) Xamarin을 사용한 모바일 개발에 대해 알아보기 (링크) (0) | 2017.04.17 |
(Xamarin) Xamarin with SQLite (0) | 2017.04.13 |
(Xamarin) "obj\Debug\android\bin\packaged_resources" 파일이 없습니다 (0) | 2017.04.13 |
(Xamarin) Xamarin 에서 Dialog 띄우기 (0) | 2017.04.13 |