Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/390.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在Android中发送任何文件格式?_Java_Android - Fatal编程技术网

Java 如何在Android中发送任何文件格式?

Java 如何在Android中发送任何文件格式?,java,android,Java,Android,我需要帮助如何在Android中发送任何文件格式。在这种情况下,我的文件格式是.jpg。如果我有.pdf或.png,我该如何做 这是我的代码: case R.id.share: Intent picMessageIntent = new Intent(android.content.Intent.ACTION_SEND); picMessageIntent.setType("image/*");

我需要帮助如何在Android中发送任何文件格式。在这种情况下,我的文件格式是.jpg。如果我有.pdf或.png,我该如何做

这是我的代码:

case R.id.share:

            Intent picMessageIntent = new Intent(android.content.Intent.ACTION_SEND);
            picMessageIntent.setType("image/*");                    
            File downloadedPic =  new File(Environment.getExternalStoragePublicDirectory("SIPRO"),value1+".jpg");

            picMessageIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(downloadedPic));
            startActivity(Intent.createChooser(picMessageIntent, "Send your picture using:"));

            return true;

我认为您希望将文件作为电子邮件附件发送。粘贴的代码应适用于任何附件类型

您是否尝试过附加不同格式的文件?如果是,那么您面临的问题是什么

我唯一能建议的更改是使用setTypetext/plain或setTypetext/html代替setTypeimage/*。确保要发送的文件在设备上可用,并且传递了正确的路径