简体   繁体   English

我想使用Android中的MMS以编程方式发送文件附件

[英]I want to send a file attachment programmatically using MMS in Android

I am working on an app to programmatically send an encrypted image file using MMS. 我正在开发一个使用MMS以编程方式发送加密图像文件的应用程序。 I am using the code in this link, http://androidbridge.blogspot.com/2011/03/how-to-send-mms-programmatically-in.html . 我正在此链接http://androidbridge.blogspot.com/2011/03/how-to-send-mms-programmatically-in.html中使用代码。

This works fine for regular images and text...but when I try sending an encrypted binary file (using the content type of application/octet-stream the receiving phone seems to strip out the file when it's delivered. 这对于常规图像和文本效果很好...但是,当我尝试发送加密的二进制文件时(使用应用程序/八位字节流的内容类型,接收电话似乎在交付文件时便剥离了该文件。

I'm looking for a way to send a text body along with an encrypted image file...has anyone gotten this to work? 我正在寻找一种将文本正文与加密的图像文件一起发送的方法...有人能做到这一点吗?

Intent sendIntent = new Intent(Intent.ACTION_SEND);
    sendIntent.putExtra("sms_body", "hi\nSend u Audio File.");
    sendIntent.setType("audio/*");  // here is for Audio file.
    sendIntent.setClassName("com.android.mms", "com.android.mms.ui.ComposeMessageActivity");
    sendIntent.putExtra("address", senderNum);

    File file1 = new File(recordFile); // file u want to attach.
    Uri uri = Uri.fromFile(file1);
    Log.e("Path:---", "" + uri);

    sendIntent.putExtra(Intent.EXTRA_STREAM, uri);
    startActivity(sendIntent);

I suppose it would depend how your image file was encrypted. 我想这将取决于您的图像文件是如何加密的。 If you were rather creative, you could try to preserve the picture header and encrypt the actual body of the image. 如果您很有创造力,则可以尝试保留图片标题并加密图像的实际主体。 I'm not sure if that encrypts everything you need/want it to encrypt, but it might be worth a shot. 我不确定是否可以加密您需要/想要加密的所有内容,但这可能值得一试。

Otherwise, you might need to go to other methods of file-sharing. 否则,您可能需要转到其他文件共享方法。 They would be a pain and not really accomplish the same simplicity as using mms, but again, it might be worth trying. 它们会很痛苦,并且不能真正实现与使用mms一样的简单性,但是同样,值得尝试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM