Notice
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- UML
- 폼메일
- 안드로이드 gcm
- Mail Server
- php 취약점
- 안드로이드 푸쉬
- soundpool
- Android
- 자동 생성
- WebView
- 우분투
- C#
- PHP
- FCM
- curl
- 자바스크립트
- android 효과음
- 안드로이드 푸시
- not working
- chart.js
- roundcube
- dovecot
- php 시큐어코딩
- mysql
- 설치
- javascript
- C# IO
- xe
- html5
- 안드로이드
Archives
- Today
- Total
그러냐
android mail send file 메일 보내기 파일 첨부 카메라 첨부파일명 지정 본문
반응형
=====파일첨부=====
http://stackoverflow.com/questions/2264622/android-multiple-email-attachment-using-intent-question
http://blog.blackmoonit.com/2010/02/filebrowser-send-receive-intents.html
public static void email(Context context, String emailTo, String emailCC,
String subject, String emailText, List<String> filePaths)
{
//need to "send multiple" to get more than one attachment
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE);
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
new String[]{emailTo});
emailIntent.putExtra(android.content.Intent.EXTRA_CC,
new String[]{emailCC});
//has to be an ArrayList
ArrayList<Uri> uris = new ArrayList<Uri>();
//convert from paths to Android friendly Parcelable Uri's
for (String file : filePaths)
{
File fileIn = new File(file);
Uri u = Uri.fromFile(fileIn);
uris.add(u);
}
emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
context.startActivity(Intent.createChooser(emailIntent, "Send mail..."));
}
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/html");
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"to@example.com"});
intent.putExtra(Intent.EXTRA_SUBJECT, "the subject");
intent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml("the content"));
intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/file.ext"));
startActivity(intent);
출처: http://javaexpert.tistory.com/305 [나는 안드로이드다.]
=====다른방식 =====
http://lastiverse.tistory.com/67
=====카메라 사진 첨부=====
public class MainActivity extends Activity {
private static final int CAMERA_REQUEST = 1888;
private ImageView imageView;
private File f;
public File getAlbumDir()
{
File storageDir = new File(
Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_PICTURES
),
"BAC/"
);
// Create directories if needed
if (!storageDir.exists()) {
storageDir.mkdirs();
}
return storageDir;
}
private File createImageFile() throws IOException {
// Create an image file name
String imageFileName =getAlbumDir().toString() +"/image.jpg";
File image = new File(imageFileName);
return image;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
this.imageView = (ImageView)this.findViewById(R.id.imageView1);
Button photoButton = (Button) this.findViewById(R.id.button1);
photoButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
f = createImageFile();
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
cameraIntent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(f));
startActivityForResult(cameraIntent, CAMERA_REQUEST);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CAMERA_REQUEST && resultCode == RESULT_OK) {
Bitmap photo = (Bitmap) data.getExtras().get("data");
imageView.setImageBitmap(photo);
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("message/rfc822");
i.putExtra(Intent.EXTRA_EMAIL , new String[]{"first.last@gmail.com"});
i.putExtra(Intent.EXTRA_SUBJECT, "first picture");
i.putExtra(Intent.EXTRA_TEXT , "body of email");
Uri uri = Uri.fromFile(f);
i.putExtra(Intent.EXTRA_STREAM, uri);
try {
startActivity(Intent.createChooser(i, "Send mail..."));
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(MainActivity.this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
}
}
}
}
=====카메라 사진 첨부 여러개=====
public static void email(Context context, String emailTo, String emailCC,
String subject, String emailText, List<String> filePaths)
{
//need to "send multiple" to get more than one attachment
final Intent emailIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
emailIntent.setType("text/plain");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
new String[]{emailTo});
emailIntent.putExtra(android.content.Intent.EXTRA_CC,
new String[]{emailCC});
emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
emailIntent.putExtra(Intent.EXTRA_TEXT, emailText);
//has to be an ArrayList
ArrayList<Uri> uris = new ArrayList<Uri>();
//convert from paths to Android friendly Parcelable Uri's
for (String file : filePaths)
{
File fileIn = new File(file);
Uri u = Uri.fromFile(fileIn);
uris.add(u);
}
emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
context.startActivity(Intent.createChooser(emailIntent, "Send mail..."));
}
포인트는
Intent emailIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
ArrayListExtra 로 보내기
반응형
'android' 카테고리의 다른 글
Encryption AES256 = C# + Objective C(ios) + PHP + JAVA(Android) + Perl + Javascript + Python (0) | 2017.01.13 |
---|---|
android onActivityResult 사용하기 (0) | 2017.01.13 |
안드로이드(Andriod) tcp ip (0) | 2017.01.10 |
이클립스 패키지명 변경 rename (0) | 2017.01.09 |
intent 브라우져 사이트 띄우기 새창 띄우기 (0) | 2016.12.29 |