开发者

How to attach a xml file to a SMS/MMS message using the Android API

开发者_运维技巧

I have a custom file type (MIME_TYPE), basically xml, that I'd like to enable users to send to each other. Implementing the email send feature with the xml file as an attachment was straight forward but I'm kinda stuck on the SMS/MMS send feature. Anyone have any guidance?

    final Intent intent = new Intent(Intent.ACTION_SEND, Uri.parse("mms://")); 
    intent.setType("text/plain"); 
    intent.putExtra("address", "2125551212");
    String url = "content://myFile.txt"; 
    intent.putExtra(Intent.EXTRA_STREAM, Uri.parse(url));
    intent.putExtra("sms_body", "some text goes here");
    startActivityForResult(Intent.createChooser(intent, "mms-sms:"), SENT_TEXT);

the intent.putExtra(Intent.EXTRA_STREAM... doesn't seem to work, I get an error message: "UNABLE TO ATTACH. FILE NOT SUPPORTED"


try this its worked with me for Send Photo. use

 Uri.fromFile

instead of

 Uri.parse

File f=new File(Environment.getExternalStorageDirectory().getAbsolutePath()+"/DCIM/Camera/"+img_name);
Intent sendIntent = new Intent(Intent.ACTION_SEND); 
sendIntent.putExtra("", ""); 
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(f));
sendIntent.setType("image/png");  
startActivity(sendIntent);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜