androidandroid-mms

how can i send the Text and the picture(url) through mms in android


Here is the code which i have tried.I just wanted to send the text and picture of the video through MMS.But i can only send the text ,but the picture is not getting attached.can any one help me.I am new to this.

ivbMessage.setOnClickListener(new OnClickListener() {
    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        try {
            imageModel = videoDetails.getVideoImagesList().get(0);
            imageUrl = imageModel.getUrl();
            System.out.println("*****" + imageUrl);

            Uri screenshotUri = Uri.parse(imageurl);
            Intent sendIntent = new Intent(Intent.ACTION_VIEW);
            sendIntent.putExtra("sms_body", imageUrl);
            sendIntent.putExtra(Intent.EXTRA_STREAM,screenshotUri);
            sendIntent.setType("Image/png");
            activity.startActivity(sendIntent);
        } catch (Exception e) {
            Toast.makeText(activity, "SMS faild, please try again later!", Toast.LENGTH_LONG).show();
            e.printStackTrace();
        }
    }
}

Solution

  • Should be:

    Intent sendIntent = new Intent(Intent.ACTION_SEND); // action must be SEND not VIEW
    sendIntent.putExtra("sms_body", "some text"); 
    sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(url));
    sendIntent.setType("image/png");  // seems like you need write with little letter here
    

    So in your code you have wrong action it should be ACTION_SEND and your type is wrong too. It should be "image/png".

    And your URL to image must be right.