To send MMS with Image

两盒软妹~` 提交于 2019-12-11 16:49:07

问题


I have my images in drawable folder and I am getting that images in gridview.Also I am showing the perticular image on selection fullscreen.Now I want to send MMS with image attachment.

Here is my code to show the image. And to send MMS.how to get Uri to put to intent or how to send the image attachment.

imageView.setImageResource(imageAdapter.mThumbIds[position]);



Intent sendIntent = new Intent(Intent.ACTION_SEND);
             sendIntent.putExtra("sms_body", "Hii");
             sendIntent.setType("image/png");

             startActivity(sendIntent);

回答1:


Use the following code to send the mms.. Hope this wil help you.

 Intent intent = new Intent(Intent.ACTION_SEND);
    intent.putExtra("sms_body", "Hi how are you");
    intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File("/sdcard/file.gif")));
    intent.setType("image/gif"); 
    startActivity(Intent.createChooser(intent,"Send"));



Uri uri = Uri.parse("android.resource://your.package.here/drawable/image_name");

EDIT:

Intent intent = new Intent(Intent.ACTION_SEND);
        intent.putExtra("sms_body", "Hi how are you");
        Uri uri = Uri.parse("android.resource:// com.example.stack/drawable/ic_launcher.png");
        intent.putExtra(Intent.EXTRA_STREAM,uri );
        intent.setType("image/png"); 
        startActivity(Intent.createChooser(intent,"Send"));


来源:https://stackoverflow.com/questions/15221810/to-send-mms-with-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!