0

I have to develop an one android application.

Here i have to attach image and sent to email .

I have using following code.

Here my image is attached..but am getting couldn't send attachedment message while click the send button .Why the getting these message ??? please review my code and give me solution for these ...

     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 :"));

EDIT:

I have changed my code look like below:

  File bitmapFile = new File(Environment.getExternalStorageDirectory()+
                                "/"+"Android/data/com.xmlparsing/image"+_Image);
                        Uri    myUri = Uri.fromFile(bitmapFile);
                        email.putExtra(Intent.EXTRA_STREAM,myUri);

Now i have to run the app and attach image means that imgae is attaching.But getting couldn't send attachment when click the Send button ...How can i resolve these errror ??? please give me solution ???

EDIT:

This is my logcat details.please check it.

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
4

1 回答 1

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:"));
于 2013-05-18T07:28:41.347 回答