我必须开发一个Android应用程序。
在这里,我必须附上图片并发送到电子邮件。
我使用了以下代码。
这里附有我的图片..但是点击发送按钮时无法发送附件信息。为什么获取这些消息???请查看我的代码,并为我提供解决方案...
Intent email = new Intent(Intent.ACTION_SEND);
email.setType("message/rfc822");
email.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
email.putExtra(Intent.EXTRA_EMAIL, new String[]
{
""
});
email.putExtra(Intent.EXTRA_SUBJECT, _Title);
File sdcard = Environment.getExternalStorageDirectory();
File f = new File (sdcard, _Image);
email.putExtra(Intent.EXTRA_STREAM,Uri.parse("file://"+File.separator+"sdcard"
+ File.separator +_Image));
//email.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(f));
startActivity(Intent.createChooser(email, "Choose an Email client :"));
修改
我的代码更改如下:
File bitmapFile = new File(Environment.getExternalStorageDirectory()+
"/"+"Android/data/com.xmlparsing/image"+_Image);
Uri myUri = Uri.fromFile(bitmapFile);
email.putExtra(Intent.EXTRA_STREAM,myUri);
现在我必须运行应用程序并附加图像意味着imgae正在附加。但是当点击发送按钮时无法发送附件...我如何解决这些错误?请给我解决方案???
修改
这是我的logcat详细信息。请检查一下。
05-18 17:45:54.351: D/AbsListView(12736): Get MotionRecognitionManager
05-18 17:45:55.836: D/AbsListView(12736): Get MotionRecognitionManager
05-18 17:45:55.922: D/libEGL(12736): loaded /vendor/lib/egl/libEGL_POWERVR_SGX540_120.so
05-18 17:45:55.929: D/libEGL(12736): loaded /vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_120.so
05-18 17:45:55.937: D/libEGL(12736): loaded /vendor/lib/egl/libGLESv2_POWERVR_SGX540_120.so
05-18 17:45:56.047: D/OpenGLRenderer(12736): Enabling debug mode 0
05-18 17:45:58.890: W/IInputConnectionWrapper(12736): showStatusIcon on inactive InputConnection
答案 0 :(得分:0)
对于图像,您可以像这样使用
Intent email = new Intent(Intent.ACTION_SEND);
email.setType("image/jpeg");
File bitmapFile = new File(Environment.getExternalStorageDirectory()+
"/"+<Name of the path folder>+"/a.jpg");
myUri = Uri.fromFile(bitmapFile);
email.putExtra(Intent.EXTRA_STREAM, myUri);
startActivity(Intent.createChooser(email, "Send your email:"));