출처: http://mashroom.tistory.com/17
* Case Email
-
private void SendEmail(String subject, String text, ArrayList<String>filePaths, String... addressTo)
{
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("image/jpeg");
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "subject");
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://"+filePaths.get(0)));
sendIntent.putExtra(Intent.EXTRA_TEXT, "Enjoy the photo");
startActivity(Intent.createChooser(sendIntent, "Email:"));
}
* Case MMS
-
private void SendMMS(Context context, ArrayList<String> urlString)
{
boolean exceptionCheck = false;
Intent sendIntent = new Intent();
// Selection count
if (urlString.size() > 1) {
sendIntent.setAction(Intent.ACTION_SEND_MULTIPLE);
} else if (urlString.size() == 1) {
sendIntent.setAction(Intent.ACTION_SEND);
} else {
Toast.makeText(this, "Please Check the Image.", Toast.LENGTH_LONG).show();
exceptionCheck = true;
}
if (!exceptionCheck) {
sendIntent.setData(Uri.parse("mmsto:"));
sendIntent.addCategory("android.intent.category.DEFAULT");
ArrayList<Uri> uris = new ArrayList<Uri>();
for (String file : urlString) {
File fileIn = new File("file://" + file);
Uri u = Uri.fromFile(fileIn);
uris.add(u);
}
sendIntent.setType("image/jpeg");
if (urlString.size() > 1) {
sendIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
} else {
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + urlString.get(0)));
}
}
try
{
startActivity(sendIntent);
} catch (Exception e) {
Toast.makeText(this, "Send Failed..", Toast.LENGTH_LONG).show();
}
}
'IT_Programming > Android_Java' 카테고리의 다른 글
GoogleMap animation with zoom (0) | 2015.06.26 |
---|---|
WebView에서 YouTube 플러그인 동작시키기 (0) | 2015.06.25 |
Swipe/Pull to Refresh for Android RecyclerView (or any other vertically scrolling view) (0) | 2015.06.24 |
Android WEAR 에만 NOTIFICATION 띄우기 (0) | 2015.06.23 |
안드로이드 여러 APK 를 하나의 어플리케이션으로 관리하기 (0) | 2015.06.23 |