May i know the reason why i am unable to send image by using following code(as MMS)

StackOverflow https://stackoverflow.com/questions/16915431

  •  31-05-2022
  •  | 
  •  

Question

i am trying to implement MMS application to send a pic/image.For that i have written below code.But after press ok message is sending like SMS not like MMS(Image is not attaching). Please help me wheter the following code is correct or not.

try {        Uri uri = Uri.parse("file://mnt/sdcard/pictures/kc.jpg");
            Intent i = new Intent(Intent.ACTION_SEND);
            i.putExtra("address",etnum.getText().toString());
            i.putExtra("sms_body",etmsg.getText().toString());
            i.putExtra(Intent.EXTRA_STREAM,"file:/"+uri);
            i.setType("image/png");
            startActivity(i);
        } catch (Exception e) {
            // TODO: handle exception
            e.printStackTrace();
        }
Was it helpful?

Solution

  1. Remove "file:/" from EXTRA_STREAM, just i.putExtra(Intent.EXTRA_STREAM, uri);
  2. Change setType to i.setType("image/*");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top