Chlock Posted March 4, 2014 Share Posted March 4, 2014 Bonjour, après avoir recuperer le resultat de la selection d'une image gallery a l'aide de Intent je voudrais la mettre en piéce jointe comme je fais ci dessous, mais comment procéder, voici mon code mais rien n'est joint public void onClick(View v) { Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); photoPickerIntent.setType("image/*"); startActivityForResult(photoPickerIntent, SELECT_PHOTO); } }); @Override protected void onActivityResult(int requestCode, int resultCode, Intent imageReturnedIntent) { super.onActivityResult(requestCode, resultCode, imageReturnedIntent); switch(requestCode) { case SELECT_PHOTO: if(resultCode == RESULT_OK){ Uri selectedImage = imageReturnedIntent.getData(); InputStream imageStream = null; try { //picturesone.setText(selectedImage.getPath()); //File file = new File(); FileDataSource datasource1 = new FileDataSource(selectedImage.getPath()); DataHandler handler1 = new DataHandler(datasource1); MimeBodyPart autruche = new MimeBodyPart(); autruche.setDataHandler(handler1); autruche.setFileName(datasource1.getName()); picturesone.setText(datasource1.getName()); } catch (MessagingException e) { e.printStackTrace(); } //Bitmap yourSelectedImage = BitmapFactory.decodeStream(imageStream); } } MimeMultipart mimeMultipart = new MimeMultipart(); try { mimeMultipart.addBodyPart(content); mimeMultipart.addBodyPart(autruche); } catch (MessagingException e) { e.printStackTrace(); } Une idée les amis pour traiter le retour du fichier afin de pouvoir le mettre en piéce jointe merci les amis Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.