2013-05-18 48 views
0

我必須開發一個Android應用程序。電子郵件附件與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 details.please檢查。

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

提供您的logcat的詳細信息。 – sachin10

+0

http://stackoverflow.com/questions/3570914/android-how-do-i-attach-a-temporary-generated-image-to-an-email – sachin10

回答

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

現在我必須運行應用程序,並附上圖像意味着imgae是附件。但是當單擊發送按鈕時無法發送附件......我如何解決這些錯誤?請給我解決方案..現在也只是一樣 – user2218667