0

I am working on a project where I need to send MMS from my android app. Below is the code which I tried but it is not working. Please advise.

Intent mmsIntent = new Intent(Intent.ACTION_SENDTO);
        mmsIntent.addCategory(Intent.CATEGORY_DEFAULT);
        mmsIntent.setType("vnd.android-dir/mms-sms");
        mmsIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));//Uri.parse(url));
        mmsIntent.setData(Uri.parse("sms:" + "89565656"));
        startActivity(mmsIntent);
Sanchit Paurush
  • 6,114
  • 17
  • 68
  • 107

2 Answers2

4

check this:

Intent i = new Intent(Intent.ACTION_SEND);
i.putExtra("address","9876543211");
i.putExtra("sms_body","hello..");
i.putExtra(Intent.EXTRA_STREAM,Uri);
i.setType("image/png");
startActivity(i);

Here Uri is:

 Uri uri = Uri.parse("content://media/external/images/media/1");

or

Uri uri = Uri.parse("file://mnt/sdcard/test.jpg");

or

Uri uri = Uri.parse("file://"+Environment.getExternalStorageDirectory()+"/test.jpg");
Dhaval Parmar
  • 18,812
  • 8
  • 82
  • 177
2

For me below code is working perfect.....

   Intent smsIntent = new Intent(android.content.Intent.ACTION_SEND);
            smsIntent.putExtra("sms_body", mContext.getString(R.string.app_name)); 
            smsIntent.putExtra(Intent.EXTRA_STREAM,Uri.parse("file://" + imagePath));
            smsIntent.setType("image/png");
            mContext.startActivity(smsIntent);
Siddhpura Amit
  • 14,534
  • 16
  • 91
  • 150