안드로이드 개발 질문/답변
(글 수 45,052)
Gmail을 통해서 다수 이미지를 복수 첨부하는 기능인데요.
메일 작성하는 부분까지는 이미지 추가 됬다고 잘 보여지는데요.
막상 보내고 보면 메일은 오는데 보냈던 텍스트만 온답니다..
제 기억으로는 처음에는 이미지도 보내졌던것 같은데..
오래만에 다시 보는거라.. 가물가물 ㅠㅠ
밑에 코드가 도움이 되실지는 모르겠지만
첨부는 됬는데 메일로 안보내지는 경우에 대해 아시는분 있으신가요 ??
RNotePicture rnotePic = null;
DBHelper emailDB = new DBHelper(activity);
// Gmail로 복수 첨부가능하게 ACTION_SEND_MULTIPLE 사용.
intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
intent.setType("image/png");
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{""});
intent.putExtra(Intent.EXTRA_SUBJECT, "");
intent.putExtra(Intent.EXTRA_TEXT, selectedNote.getMemo());
try {
// getUid 로 DB읽어오기
emailDB.open();
selectedNote = emailDB.getOneNote(selectedNote.getUid());
} catch (SQLException e1) {
e1.printStackTrace();
} finally {
emailDB.close();
}
// 이미지가 한 개 이상이기 때문에 Uri를 ArrayList로 받는다.
ArrayList<Uri> uriList = new ArrayList<Uri>();
// getPics가 가지고 있는 이미지 개수 많큼 ..
for(int i =0; i< selectedNote.getPics().size();i++){
rnotePic = selectedNote.getPics().get(i);
Bitmap bitmap = BitmapFactory.decodeByteArray(
rnotePic.getPic(), 0, rnotePic.getPic().length);
// 이미지 저장
File file = new File ( Environment.getExternalStorageDirectory(), "RNoteImage_"+i+".png");
Constants.fileList.add(file);
try {
file.createNewFile();
OutputStream OpS = new FileOutputStream(file);
// bmp 이미지 파일을 png 파일로 변환해주는 부분
bitmap.compress(Bitmap.CompressFormat.PNG, 100, OpS);
OpS.close();
} catch (IOException e) {
e.printStackTrace();
}
Uri bitmapURI = Uri.fromFile(file); // <- file:///~ 형태의 URI
uriList.add(bitmapURI);
}
intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uriList);
activity.startActivity(intent);
break;