마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

폰의 이미지를 웹서버에 전송하려고 합니다. [closed]

0 추천

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 이라는 값이 나오는데요.

이게 뭘 의미하는 것인지, 이걸 어떤식으로 웹서버에 전송해야 할지 모르겠습니다.

안드로이드에 대허 전혀 몰라서 질문이 제대로 된것인지도 의문입니다.;

충고 말씀 부탁 드립니다.

질문을 종료한 이유: 해결이 되었습니다.
icham (260 포인트) 님이 2017년 5월 30일 질문
icham님이 2017년 5월 30일 closed

1개의 답변

0 추천
 
채택된 답변

toString은 object 정보가 찍히는 것이라 .안나옵니다.

Bitmap  compress로 전송하세요..

아래는  직접 전송하는 예제입니다.

    URL url = new URL("보낼주소");
    con = (HttpURLConnection)url.openConnection(); 
    con.setRequestMethod("POST");
    con.setDoOutput(true);
    OutputStream out = con.getOutputStream();
    bitmap.compress(Bitmap.CompressFormat.JPEG, 100, out);
    out.close();

 

익명사용자 님이 2017년 5월 30일 답변
icham님이 2017년 5월 30일 채택됨
도움이 되었습니다.
답변 감사합니다.
...