Search code examples
androidandroid-intentmms

How to send MMS from Android App?


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);

Solution

  • 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");