[android] send MMS with drawable image

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

 

try
{
  Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
  File file = new File(getExternalCacheDir().toString(), "ic_launcher.PNG");
  FileOutputStream outStream = new FileOutputStream(file);
  bm.compress(Bitmap.CompressFormat.PNG, 100, outStream);
  outStream.flush();
  outStream.close();
  
  Intent intent = new Intent(Intent.ACTION_SEND);
  intent.putExtra("address", "01234567890");
  intent.putExtra("sms_body", "some text");
  intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
  intent.setType("image/png");
  startActivity(intent);
}
catch (Exception e)
{
  e.printStackTrace();
}

 

th_device-2014-11-19-152248

 

도움받은 곳 :

http://stackoverflow.com/questions/12559974/save-images-from-drawable-to-internal-file-storage-in-android

http://stackoverflow.com/questions/16518393/send-mms-programmatically