mms를 수신할때 해당 mms에 이미지가 첨부되어 있으면, 해당 이미지도 웹서버에 함게 전송하려고 합니다.
text내용,발신번호는 가져왔고, 첨부된 이미지는 다음의 코드로 가져 왔습니다.
Bitmap img = parseImage(id);
private Bitmap parseImage(String $id){
Bitmap bitmap = null;
String selectionPart = "mid=" + $id;
Uri uri = Uri.parse("content://mms/part");
Cursor cPart = _context.getContentResolver().query(uri, null,
selectionPart, null, null);
if (cPart.moveToFirst()) {
do {
String partId = cPart.getString(cPart.getColumnIndex("_id"));
String type = cPart.getString(cPart.getColumnIndex("ct"));
if ("image/jpeg".equals(type) || "image/bmp".equals(type) ||
"image/gif".equals(type) || "image/jpg".equals(type) ||
"image/png".equals(type)) {
bitmap = getMmsImage(partId);
}
} while (cPart.moveToNext());
}
return bitmap;
}
private Bitmap getMmsImage(String _id){
Uri partURI = Uri.parse("content://mms/part/"+_id);
InputStream is = null;
Bitmap bitmap = null;
try {
is = _context.getContentResolver().openInputStream(partURI);
bitmap = BitmapFactory.decodeStream(is);
}catch (IOException e){}
finally {
if(is != null){
try {
is.close();
}catch (IOException e){}
}
}
return bitmap;
}
이렇게 하고 img.toString()으로 찍어보면 android.graphics.Bitmap@9224488 이라는 값이 나오는데요.
이게 뭘 의미하는 것인지, 이걸 어떤식으로 웹서버에 전송해야 할지 모르겠습니다.
안드로이드에 대허 전혀 몰라서 질문이 제대로 된것인지도 의문입니다.;
충고 말씀 부탁 드립니다.